zz::log Namespace Reference

Namespace for logging and message stuffs. More...

Classes

class  LogConfig
 The LogConfig class. For get/set logging configurations. More...
 
class  Logger
 The Logger class Logger is the object to be called to log some message. Each logger may links to several Sinks as logging destinations. More...
 
class  ProgBar
 The Progress bar class. For simple progress bar. More...
 

Typedefs

typedef std::shared_ptr< LoggerLoggerPtr
 

Functions

std::string level_mask_to_string (int levelMask)
 
LogLevels level_from_str (std::string level)
 
int level_mask_from_string (std::string levels)
 
LoggerPtr get_logger (std::string name, bool createIfNotExists=true)
 Get logger by name. More...
 
SinkPtr new_stdout_sink ()
 Get the sink pointer to stdout. More...
 
SinkPtr new_stderr_sink ()
 Get the sink pointer to stderr. More...
 
SinkPtr get_sink (std::string name)
 Get the sink pointer from name provided. Return nullptr if sink does not exist. More...
 
void dump_loggers (std::ostream &out=std::cout)
 Dump all loggers info. More...
 
SinkPtr new_ostream_sink (std::ostream &stream, std::string name, bool forceFlush=false)
 Create new ostream sink from existing ostream. More...
 
SinkPtr new_simple_file_sink (std::string filename, bool truncate=false)
 Create new simple file sink withe filename provided. More...
 
SinkPtr new_rotate_file_sink (std::string filename, std::size_t maxSizeInByte=4194304, bool backupOld=false)
 Create new rotate file sink. More...
 
void lock_loggers ()
 Lock all loggers. When locked, loggers cannot be modified.
 
void unlock_loggers ()
 Unlock all loggers. When locked, loggers cannot be modified.
 
void drop_logger (std::string name)
 Delete a logger with the name given. More...
 
void drop_all_loggers ()
 Delete all loggers.
 
void drop_sink (std::string name)
 Delete the sink, detach it from every logger. More...
 
void config_from_file (std::string cfgFilename)
 Config loggers from a config file. More...
 
void config_from_stringstream (std::stringstream &ss)
 Config loggers from a stringstream. More...
 

Detailed Description

Namespace for logging and message stuffs.

Function Documentation

void zz::log::config_from_file ( std::string  cfgFilename)

Config loggers from a config file.

Parameters
cfgFilename
void zz::log::config_from_stringstream ( std::stringstream &  ss)

Config loggers from a stringstream.

Parameters
ssStringstream where configs stored
void zz::log::drop_logger ( std::string  name)

Delete a logger with the name given.

Parameters
name
void zz::log::drop_sink ( std::string  name)

Delete the sink, detach it from every logger.

Parameters
name
void zz::log::dump_loggers ( std::ostream &  out = std::cout)

Dump all loggers info.

Parameters
outThe stream where you want the info direct to, default std::cout
LoggerPtr zz::log::get_logger ( std::string  name,
bool  createIfNotExists = true 
)

Get logger by name.

Parameters
name
createIfNotExistsCreate new logger with the name provided if not exist.
Returns
Shared pointer to the logger.
SinkPtr zz::log::get_sink ( std::string  name)

Get the sink pointer from name provided. Return nullptr if sink does not exist.

Returns
Shared pointer to sink.
SinkPtr zz::log::new_ostream_sink ( std::ostream &  stream,
std::string  name,
bool  forceFlush = false 
)

Create new ostream sink from existing ostream.

Parameters
stream
name
forceFlush
Returns
Shared pointer to the new sink.
SinkPtr zz::log::new_rotate_file_sink ( std::string  filename,
std::size_t  maxSizeInByte = 4194304,
bool  backupOld = false 
)

Create new rotate file sink.

Parameters
filename
maxSizeInByteMaximum size in byte, sink will truncate the file and rewrite new content if exceed this size.
backupOldWhether keep backups of the old files.
Returns
Shared pointer to the new sink
SinkPtr zz::log::new_simple_file_sink ( std::string  filename,
bool  truncate = false 
)

Create new simple file sink withe filename provided.

Parameters
filename
truncateOpen the file in truncate mode?
Returns
Shared pointer to the new sink.
SinkPtr zz::log::new_stderr_sink ( )

Get the sink pointer to stderr.

Returns
Shared pointer to stderr sink.
SinkPtr zz::log::new_stdout_sink ( )

Get the sink pointer to stdout.

Returns
Shared pointer to stdout sink.