mirror of
https://github.com/FairRootGroup/FairLogger.git
synced 2025-10-13 08:41:12 +00:00
Logger: handle nullptr.
This commit is contained in:
parent
a9f9030041
commit
42470d2090
|
@ -470,7 +470,7 @@ void Logger::RemoveCustomSink(const string& key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ostringstream& Logger::Log()
|
Logger& Logger::Log()
|
||||||
{
|
{
|
||||||
char tsstr[32];
|
char tsstr[32];
|
||||||
if (!strftime(tsstr, sizeof(tsstr), "%H:%M:%S", localtime(&(fMetaData.timestamp))))
|
if (!strftime(tsstr, sizeof(tsstr), "%H:%M:%S", localtime(&(fMetaData.timestamp))))
|
||||||
|
@ -522,7 +522,19 @@ ostringstream& Logger::Log()
|
||||||
fColorOut << " ";
|
fColorOut << " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return fContent;
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger& Logger::operator<<(ios_base& (*manip) (ios_base&))
|
||||||
|
{
|
||||||
|
fContent << manip;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger& Logger::operator<<(ostream& (*manip) (ostream&))
|
||||||
|
{
|
||||||
|
fContent << manip;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::~Logger() noexcept(false)
|
Logger::~Logger() noexcept(false)
|
||||||
|
|
|
@ -144,7 +144,35 @@ class Logger
|
||||||
static void AddCustomSink(const std::string& key, const std::string& severityStr, std::function<void(const std::string& content, const LogMetaData& metadata)> sink);
|
static void AddCustomSink(const std::string& key, const std::string& severityStr, std::function<void(const std::string& content, const LogMetaData& metadata)> sink);
|
||||||
static void RemoveCustomSink(const std::string& key);
|
static void RemoveCustomSink(const std::string& key);
|
||||||
|
|
||||||
std::ostringstream& Log();
|
Logger& Log();
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
Logger& operator<<(const T& t)
|
||||||
|
{
|
||||||
|
fContent << t;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// overload for char* to make sure it is not nullptr
|
||||||
|
Logger& operator<<(const char* cptr)
|
||||||
|
{
|
||||||
|
if (cptr != nullptr) {
|
||||||
|
fContent << cptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// overload for char* to make sure it is not nullptr
|
||||||
|
Logger& operator<<(char* cptr)
|
||||||
|
{
|
||||||
|
if (cptr != nullptr) {
|
||||||
|
fContent << cptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger& operator<<(std::ios_base& (*manip) (std::ios_base&));
|
||||||
|
Logger& operator<<(std::ostream& (*manip) (std::ostream&));
|
||||||
|
|
||||||
static const std::unordered_map<std::string, Verbosity> fVerbosityMap;
|
static const std::unordered_map<std::string, Verbosity> fVerbosityMap;
|
||||||
static const std::unordered_map<std::string, Severity> fSeverityMap;
|
static const std::unordered_map<std::string, Severity> fSeverityMap;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user