dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
29 #ifndef common_logger_hpp
30 #define common_logger_hpp
96 void fatal(
const std::string &message );
103 void error(
const std::string &message );
110 void warning(
const std::string &message );
117 void info(
const std::string &message );
124 void statistics(
const std::string &message );
131 void debug(
const std::string &message );
138 void trace(
const std::string &message );
190 void log(
LogLevel level,
const std::string &message );
271 #define log_Fatal( what ) common::Logger::getLogger()->fatal( dodo::common::Puts() << what )
277 #define log_Error( what ) common::Logger::getLogger()->error( dodo::common::Puts() << what )
283 #define log_Warning( what ) common::Logger::getLogger()->warning( dodo::common::Puts() << what )
289 #define log_Info( what ) common::Logger::getLogger()->info( dodo::common::Puts() << what )
295 #define log_Statistics( what ) common::Logger::getLogger()->statistics( dodo::common::Puts() << what )
302 #define log_Debug( what ) common::Logger::getLogger()->debug( dodo::common::Puts() << what )
304 #define log_Debug( what )
312 #define log_Trace( what ) common::Logger::getLogger()->trace( dodo::common::Puts() << what )
314 #define log_Trace( what )
size_t max_file_trail
The maximum number of files to keep besides the active log file.
static std::string LogLevelAsString(LogLevel level, bool acronym)
Return the LogLevel as a string (as used in console and file).
@ Error
The program signaled an error.
FileParams file_params_
Parameters for the file Destination.
void error(const std::string &message)
Log a Error log entry.
static threads::Mutex mutex_
threads::Mutex to serialize log writing.
int facility
The syslog facility to use.
void log(LogLevel level, const std::string &message)
Log a log entry.
std::string active_log
the filename of the active log
void getFileParams(const Config &config)
Get FileParams from the Config into file_params_.
Logger(const Config &config)
Construct against a config.
void statistics(const std::string &message)
Log a Statistics log entry.
@ Statistics
The program signaled runtime statistics.
size_t filesize
current file size
virtual ~Logger()
Destructor.
static Logger * logger_
The singleton.
@ Fatal
The program could not continue.
void warning(const std::string &message)
Log a Warning log entry.
void debug(const std::string &message)
Log a Debug log entry.
std::ofstream file
the ofstream of the active log.
A Mutex to synchronize access to resources between threads.
@ Warning
The program signaled a warning.
std::map< uint8_t, LogLevel > levels_
Map Destination to LogLevel.
std::string hostname_
The hostname cached in the constructor.
std::string formatMessage(LogLevel level, const std::string &message)
Format a LogLine.
@ Trace
The program produced trace info.
Singleton interface to a (read-only) deployment configuration, combining data from the deployment con...
Destination
Destination flags.
void trace(const std::string &message)
Log a Trace log entry.
@ Info
The program signaled an informational message.
size_t max_size_mib
The maximum size of a logfile.
SyslogParams syslog_params_
Parameters for the syslog Destination.
static Logger * getLogger()
Get the Logger singleton - initialize() must have been called first.
Common and utility interfaces.
static Logger * initialize(const Config &config)
Initialize the Logger singleton.
LogLevel
The level of a log entry.
uint8_t destinations_
Destinations as bit flags.
int mapLeveltoSyslog(LogLevel level)
Map a LogLevel to a syslog level.
Red tape wrapper class for applications, from command line to services.
void fatal(const std::string &message)
Log a Fatal log entry.
void info(const std::string &message)
Log a Info log entry.
size_t rotate_throttle_counter_
Track when rotation was last checked.
static LogLevel StringAsLogLevel(const std::string slevel)
Return the string as a LogLevel.
void checkRotate()
Check and rotate the log file if it exceeds the size limit, delete older logs if needed.
syslog logging parameters.
@ Debug
The program produced debug info.
std::string directory
The directory to write the log files in.