25 #ifndef __XRD_CL_LOG_HH__
26 #define __XRD_CL_LOG_HH__
58 virtual void Write(
const std::string &message ) = 0;
73 bool Open(
const std::string &fileName );
79 virtual void Write(
const std::string &message );
91 virtual void Write(
const std::string &message );
119 Log(): pLevel(
NoMsg ), pTopicMaxLength( 18 ), pPid(0)
123 for(
int i = 0; i < maxMask; ++i )
124 pMask[i] = 0xffffffffffffffffULL;
138 void Error( uint64_t topic,
const char *format, ... )
139 #if defined(__GNUC__)
147 void Warning( uint64_t topic,
const char *format, ... )
148 #if defined(__GNUC__)
156 void Info( uint64_t topic,
const char *format, ... )
157 #if defined(__GNUC__)
165 void Debug( uint64_t topic,
const char *format, ... )
166 #if defined(__GNUC__)
174 void Dump( uint64_t topic,
const char *format, ... )
175 #if defined(__GNUC__)
188 void Say(
LogLevel level, uint64_t topic,
const char *format, va_list list );
195 #if __cplusplus >= 201103L
196 pLevel.store(level, std::memory_order_relaxed);
208 if( StringToLogLevel( level, lvl ) )
232 void SetMask(
const std::string &level, uint64_t mask )
235 if( StringToLogLevel( level, lvl ) )
250 uint64_t tpcnb = pTopicMap.rbegin()->first << 1;
260 LogLevel lvl = pLevel.load(std::memory_order_relaxed);
273 typedef std::map<uint64_t, std::string> TopicMap;
274 std::string LogLevelToString(
LogLevel level );
275 bool StringToLogLevel(
const std::string &strLevel,
LogLevel &level );
276 std::string TopicToString( uint64_t topic );
278 std::atomic<LogLevel> pLevel;
283 uint32_t pTopicMaxLength;
Write log messages to stderr.
virtual void Write(const std::string &message)
Write log messages to a file.
virtual void Write(const std::string &message)
void Close()
Close the log file.
bool Open(const std::string &fileName)
Open the log file.
Interface for logger outputs.
virtual void Write(const std::string &message)=0
void SetLevel(const std::string &level)
Set the level of the messages that should be sent to the destination.
@ WarningMsg
report warnings
@ DebugMsg
print debug info
@ DumpMsg
print details of the request and responses
uint64_t RegisterTopic(const std::string &topic)
Register new topic.
void SetMask(LogLevel level, uint64_t mask)
Sets the mask for the topics of messages that should be printed.
void SetTopicName(uint64_t topic, std::string name)
Map a topic number to a string.
void SetMask(const std::string &level, uint64_t mask)
Sets the mask for the topics of messages that should be printed.
void SetLevel(LogLevel level)
Set the level of the messages that should be sent to the destination.
void Error(uint64_t topic, const char *format,...)
Report an error.
LogLevel GetLevel() const
Get the log level.
void Warning(uint64_t topic, const char *format,...)
Report a warning.
void Dump(uint64_t topic, const char *format,...)
Print a dump message.
void Info(uint64_t topic, const char *format,...)
Print an info.
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
void Say(LogLevel level, uint64_t topic, const char *format, va_list list)
void SetOutput(LogOut *output)
Set the output that should be used.
void SetPid(pid_t pid)
Set pid.