Nymph  v1.5.2
Flow-Based Data Processing Framework
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
KTLogger Class Reference

#include <KTLogger.hh>

Classes

struct  Location
 
struct  Private
 

Public Types

enum  ELevel {
  eTrace, eDebug, eInfo, eProg,
  eWarn, eError, eFatal
}
 

Public Member Functions

 KTLogger (const char *name=0)
 
 KTLogger (const std::string &name)
 
virtual ~KTLogger ()
 
bool IsLevelEnabled (ELevel level) const
 
void SetLevel (ELevel level) const
 
void Log (ELevel level, const std::string &message, const Location &loc=Location())
 
void LogTrace (const std::string &message, const Location &loc=Location())
 
void LogDebug (const std::string &message, const Location &loc=Location())
 
void LogInfo (const std::string &message, const Location &loc=Location())
 
void LogProg (const std::string &message, const Location &loc=Location())
 
void LogWarn (const std::string &message, const Location &loc=Location())
 
void LogError (const std::string &message, const Location &loc=Location())
 
void LogFatal (const std::string &message, const Location &loc=Location())
 

Static Public Member Functions

static KTLoggerGetRootLogger ()
 

Private Attributes

PrivatefPrivate
 

Detailed Description

The Nymph logger.

The usage and syntax is inspired by log4j. logger itself uses the log4cxx library if it was available on the system during compiling, otherwise it falls back to std::stream.

The logger output can be configured in a file specified with the environment variable LOGGER_CONFIGURATION (by default log4cxx.properties in the config directory).

In most cases the following macro can be used to instantiate a Logger in your code:

LOGGER(myLogger, "loggerName");

This is equivalent to:

static Nymph::logger myLogger("loggerName");

For logging the following macros can be used. The source code location will then automatically included in the output:

KTLOG(myLogger, level, "message");
KTTRACE(myLogger, "message");
KTDEBUG(myLogger, "message");
KTINFO(myLogger, "message");
KTPROG(myLogger, "message");
KTWARN(myLogger, "message");
KTERROR(myLogger, "message");
KTFATAL(myLogger, "message");
KTASSERT(myLogger, assertion, "message");
KTLOG_ONCE(myLogger, level, "message");
KTTRACE_ONCE(myLogger, "message");
KTDEBUG_ONCE(myLogger, "message");
KTINFO_ONCE(myLogger, "message");
KTPROG_ONCE(myLogger, "message");
KTWARN_ONCE(myLogger, "message");
KTERROR_ONCE(myLogger, "message");
KTFATAL_ONCE(myLogger, "message");

Definition at line 121 of file KTLogger.hh.

Member Enumeration Documentation

◆ ELevel

enum ELevel
Enumerator
eTrace 
eDebug 
eInfo 
eProg 
eWarn 
eError 
eFatal 

Definition at line 124 of file KTLogger.hh.

Constructor & Destructor Documentation

◆ KTLogger() [1/2]

KTLogger ( const char *  name = 0)

Standard constructor assigning a name to the logger instance.

Parameters
nameThe logger name.

Definition at line 138 of file KTLogger.cc.

◆ KTLogger() [2/2]

KTLogger ( const std::string &  name)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 154 of file KTLogger.cc.

◆ ~KTLogger()

~KTLogger ( )
virtual

Definition at line 162 of file KTLogger.cc.

Member Function Documentation

◆ GetRootLogger()

static KTLogger& GetRootLogger ( )
inlinestatic

Definition at line 143 of file KTLogger.hh.

◆ IsLevelEnabled()

bool IsLevelEnabled ( ELevel  level) const

Check whether a certain log-level is enabled.

Parameters
levelThe log level as string representation.
Returns

Definition at line 167 of file KTLogger.cc.

◆ Log()

void Log ( ELevel  level,
const std::string &  message,
const Location loc = Location() 
)

Log a message with the specified level. Use the macro LOG(logger, level, message).

Parameters
levelThe log level.
messageThe message.
locSource code location (set automatically by the corresponding macro).

Definition at line 183 of file KTLogger.cc.

◆ LogDebug()

void LogDebug ( const std::string &  message,
const Location loc = Location() 
)
inline

Log a message at DEBUG level. Use the macro DEBUG(logger, message).

Parameters
messageThe message.
locSource code location (set automatically by the corresponding macro).

Definition at line 197 of file KTLogger.hh.

◆ LogError()

void LogError ( const std::string &  message,
const Location loc = Location() 
)
inline

Log a message at ERROR level. Use the macro ERROR(logger, message).

Parameters
messageThe message.
locSource code location (set automatically by the corresponding macro).

Definition at line 237 of file KTLogger.hh.

◆ LogFatal()

void LogFatal ( const std::string &  message,
const Location loc = Location() 
)
inline

Log a message at FATAL level. Use the macro FATAL(logger, message).

Parameters
messageThe message.
locSource code location (set automatically by the corresponding macro).

Definition at line 247 of file KTLogger.hh.

◆ LogInfo()

void LogInfo ( const std::string &  message,
const Location loc = Location() 
)
inline

Log a message at INFO level. Use the macro INFO(logger, message).

Parameters
messageThe message.
locSource code location (set automatically by the corresponding macro).

Definition at line 207 of file KTLogger.hh.

◆ LogProg()

void LogProg ( const std::string &  message,
const Location loc = Location() 
)
inline

Log a message at PROG level. Use the macro PROG(logger, message).

Parameters
messageThe message.
locSource code location (set automatically by the corresponding macro).

Definition at line 217 of file KTLogger.hh.

◆ LogTrace()

void LogTrace ( const std::string &  message,
const Location loc = Location() 
)
inline

Log a message at TRACE level. Use the macro TRACE(logger, message).

Parameters
messageThe message.
locSource code location (set automatically by the corresponding macro).

Definition at line 187 of file KTLogger.hh.

◆ LogWarn()

void LogWarn ( const std::string &  message,
const Location loc = Location() 
)
inline

Log a message at WARN level. Use the macro WARN(logger, message).

Parameters
messageThe message.
locSource code location (set automatically by the corresponding macro).

Definition at line 227 of file KTLogger.hh.

◆ SetLevel()

void SetLevel ( ELevel  level) const

Set a loggers minimum logging level

Parameters
levelstring identifying the log level

Definition at line 172 of file KTLogger.cc.

Member Data Documentation

◆ fPrivate

Private* fPrivate
private

Definition at line 253 of file KTLogger.hh.


The documentation for this class was generated from the following files: