OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022

#include <Log.hpp>

Public Member Functions

 Log ()
 
 Log (bool default_loggers)
 
void add (std::unique_ptr< LogFacility > target)
 
void add (int min_severity, std::unique_ptr< LogFacility > target)
 
void add (int min_severity, int max_severity, std::unique_ptr< LogFacility > target)
 
void log_raw (int severity, const std::string &s)
 
void log (int severity, const std::string &s)
 
template<typename... Arguments>
void log (int severity, const std::string &fmt, const Arguments &... args)
 
void log (LogSeverity severity, const std::string &s)
 
template<typename... Arguments>
void log (LogSeverity severity, const std::string &fmt, const Arguments &... args)
 
void add (LogSeverity min_severity, std::unique_ptr< LogFacility > target)
 
void add (LogSeverity min_severity, LogSeverity max_severity, std::unique_ptr< LogFacility > target)
 
void log_raw (LogSeverity severity, const std::string &s)
 
void debug (const std::string &s)
 
template<typename... Arguments>
void debug (const std::string &s, const Arguments &... args)
 
void info (const std::string &s)
 
template<typename... Arguments>
void info (const std::string &s, const Arguments &... args)
 
void notice (const std::string &s)
 
template<typename... Arguments>
void notice (const std::string &s, const Arguments &... args)
 
void warning (const std::string &s)
 
template<typename... Arguments>
void warning (const std::string &s, const Arguments &... args)
 
void error (const std::string &s)
 
template<typename... Arguments>
void error (const std::string &s, const Arguments &... args)
 
void critical (const std::string &s)
 
template<typename... Arguments>
void critical (const std::string &s, const Arguments &... args)
 
void alert (const std::string &s)
 
template<typename... Arguments>
void alert (const std::string &s, const Arguments &... args)
 
void emergency (const std::string &s)
 
template<typename... Arguments>
void emergency (const std::string &s, const Arguments &... args)
 
void warn (const std::string &s)
 
template<typename... Arguments>
void warn (const std::string &s, const Arguments &... args)
 
void err (const std::string &s)
 
template<typename... Arguments>
void err (const std::string &s, const Arguments &... args)
 
void crit (const std::string &s)
 
template<typename... Arguments>
void crit (const std::string &s, const Arguments &... args)
 
void emerg (const std::string &s)
 
template<typename... Arguments>
void emerg (const std::string &s, const Arguments &... args)
 
size_t num_loggers ()
 
LogSeverity severity ()
 

Static Public Member Functions

static Logget_default ()
 

Friends

Logoperator<< (Log &me, LogSeverity severity)
 
Logoperator<< (Log &me, const std::string &t)
 
template<typename T >
Logoperator<< (Log &me, const T &t)
 

Detailed Description

Multiple output, versatile logger.

NB: log severities are backwards; e.g., debug is numerically larger than emergency, but is considered lower severity. Thus, min_severity and max_severity throughout are referring to severity, not numeric representation, which were copied from syslog's paradigm.

Example

Definition at line 42 of file Log.hpp.

Constructor & Destructor Documentation

◆ Log() [1/2]

Log ( )
inline

Default constructor with no output facilities.

Definition at line 45 of file Log.hpp.

◆ Log() [2/2]

Log ( bool  default_loggers)
inlineexplicit

Default constructor, optionally creating default facilities.

Parameters
default_loggerswhether or not to add default facilities

Definition at line 51 of file Log.hpp.

Member Function Documentation

◆ add() [1/5]

void add ( int  min_severity,
int  max_severity,
std::unique_ptr< LogFacility target 
)
inline

Add new log facility with given minimum and maximum severities.

Parameters
min_severityMinimum severity to log
max_severityMaximum severity to log
targetNew log facility to add

Definition at line 94 of file Log.hpp.

◆ add() [2/5]

void add ( int  min_severity,
std::unique_ptr< LogFacility target 
)
inline

Add new log facility with a given minimum severity and no maximum.

Parameters
min_severityMinimum severity to log
targetNew log facility to add

Definition at line 84 of file Log.hpp.

◆ add() [3/5]

void add ( LogSeverity  min_severity,
LogSeverity  max_severity,
std::unique_ptr< LogFacility target 
)
inline

Add new log facility with given minimum and maximum severities.

Parameters
min_severityMinimum severity to log
max_severityMaximum severity to log
targetNew log facility to add

Definition at line 193 of file Log.hpp.

◆ add() [4/5]

void add ( LogSeverity  min_severity,
std::unique_ptr< LogFacility target 
)
inline

Add new log facility with a given minimum severity and no maximum.

Parameters
min_severityMinimum severity to log
targetNew log facility to add

Definition at line 183 of file Log.hpp.

◆ add() [5/5]

void add ( std::unique_ptr< LogFacility target)
inline

Add new log facility, using default severity filter (info severity and above)

Parameters
targetPointer to log facility to add

Definition at line 75 of file Log.hpp.

◆ alert() [1/2]

void alert ( const std::string s)
inline

Log a message with alert severity.

Parameters
smessage to log

Definition at line 291 of file Log.hpp.

◆ alert() [2/2]

void alert ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with alert severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 299 of file Log.hpp.

◆ crit() [1/2]

void crit ( const std::string s)
inline

Log a message with critical severity.

Parameters
smessage to log

Definition at line 344 of file Log.hpp.

◆ crit() [2/2]

void crit ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with critical severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 352 of file Log.hpp.

◆ critical() [1/2]

void critical ( const std::string s)
inline

Log a message with critical severity.

Parameters
smessage to log

Definition at line 278 of file Log.hpp.

◆ critical() [2/2]

void critical ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with critical severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 286 of file Log.hpp.

◆ debug() [1/2]

void debug ( const std::string s)
inline

Log a message with debug severity.

Parameters
smessage to log

Definition at line 213 of file Log.hpp.

◆ debug() [2/2]

void debug ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with debug severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 221 of file Log.hpp.

◆ emerg() [1/2]

void emerg ( const std::string s)
inline

Log a message with emergency severity.

Parameters
smessage to log

Definition at line 357 of file Log.hpp.

◆ emerg() [2/2]

void emerg ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with emergency severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 365 of file Log.hpp.

◆ emergency() [1/2]

void emergency ( const std::string s)
inline

Log a message with emergency severity.

Parameters
smessage to log

Definition at line 304 of file Log.hpp.

◆ emergency() [2/2]

void emergency ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with emergency severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 312 of file Log.hpp.

◆ err() [1/2]

void err ( const std::string s)
inline

Log a message with error severity.

Parameters
smessage to log

Definition at line 331 of file Log.hpp.

◆ err() [2/2]

void err ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with error severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 339 of file Log.hpp.

◆ error() [1/2]

void error ( const std::string s)
inline

Log a message with error severity.

Parameters
smessage to log

Definition at line 265 of file Log.hpp.

◆ error() [2/2]

void error ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with error severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 273 of file Log.hpp.

◆ get_default()

static Log& get_default ( )
inlinestatic

Obtain a singleton of the default logger.

Thread-safe after C++11's additions of magic statics.

Definition at line 65 of file Log.hpp.

◆ info() [1/2]

void info ( const std::string s)
inline

Log a message with info severity.

Parameters
smessage to log

Definition at line 226 of file Log.hpp.

◆ info() [2/2]

void info ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with info severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 234 of file Log.hpp.

◆ log() [1/4]

void log ( int  severity,
const std::string fmt,
const Arguments &...  args 
)
inline

Log a message with a given (numeric) severity, performing i18n in the process.

TODO: don't call boost::format if no loggers will use this message (lower cost for oft-hidden debug messages)

Template Parameters
Argumentsarbitrary argument types
Parameters
severitynumeric severity of message
fmtboost::format string
argsformat parameters

Definition at line 141 of file Log.hpp.

◆ log() [2/4]

void log ( int  severity,
const std::string s 
)
inline

Log a message with a given (numeric) severity, performing i18n in the process.

Parameters
severitynumeric severity of message
smessage to log

Definition at line 120 of file Log.hpp.

◆ log() [3/4]

void log ( LogSeverity  severity,
const std::string fmt,
const Arguments &...  args 
)
inline

Log a message with a given severity, performing i18n in the process.

Template Parameters
Argumentsarbitrary argument types
Parameters
severitynumeric severity of message
fmtboost::format string
argsformat parameters

Definition at line 173 of file Log.hpp.

◆ log() [4/4]

void log ( LogSeverity  severity,
const std::string s 
)
inline

Log a message with a given severity.

Parameters
severityseverity of message
smessage to log

Definition at line 160 of file Log.hpp.

◆ log_raw() [1/2]

void log_raw ( int  severity,
const std::string s 
)
inline

Log a message with a given (numeric) severity.

Every other logging function is a wrapper around this.

Parameters
severitynumeric severity of message
smessage to log

Definition at line 106 of file Log.hpp.

◆ log_raw() [2/2]

void log_raw ( LogSeverity  severity,
const std::string s 
)
inline

Log a message with a given (numeric) severity.

Every other logging function is a wrapper around this.

Parameters
severitynumeric severity of message
smessage to log

Definition at line 205 of file Log.hpp.

◆ notice() [1/2]

void notice ( const std::string s)
inline

Log a message with notice severity.

Parameters
smessage to log

Definition at line 239 of file Log.hpp.

◆ notice() [2/2]

void notice ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with notice severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 247 of file Log.hpp.

◆ num_loggers()

size_t num_loggers ( )
inline

Check number of log facilities.

Returns
number of log facilities

Definition at line 372 of file Log.hpp.

◆ severity()

LogSeverity severity ( )
inline

Return the default severity (only used for stream operators)

Returns
default severity

Definition at line 378 of file Log.hpp.

◆ warn() [1/2]

void warn ( const std::string s)
inline

Log a message with warning severity.

Parameters
smessage to log

Definition at line 318 of file Log.hpp.

◆ warn() [2/2]

void warn ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with warning severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 326 of file Log.hpp.

◆ warning() [1/2]

void warning ( const std::string s)
inline

Log a message with warning severity.

Parameters
smessage to log

Definition at line 252 of file Log.hpp.

◆ warning() [2/2]

void warning ( const std::string s,
const Arguments &...  args 
)
inline

Log a message with warning severity.

Template Parameters
Argumentsarbitrary argument types
Parameters
smessage to log
argsformat parameters

Definition at line 260 of file Log.hpp.

Friends And Related Function Documentation

◆ operator<< [1/3]

Log& operator<< ( Log me,
const std::string t 
)
friend

log a message via stream operator, using default log severity

The stream operators do not provide i18n.

Parameters
methis logger
tmessage to log
Returns
this logger, for chaining

Definition at line 402 of file Log.hpp.

◆ operator<< [2/3]

Log& operator<< ( Log me,
const T &  t 
)
friend

log a non-string object via stream operator, using default log severity

This function will use a standard stringbuf and ostream to convert the input to a string. The stream operators do not provide i18n.

Parameters
methis logger
tnon-string object to log
Returns
this logger, for chaining

Definition at line 418 of file Log.hpp.

◆ operator<< [3/3]

Log& operator<< ( Log me,
LogSeverity  severity 
)
friend

set the default severity for stream operators

Parameters
methis logger
severitynew, default log severity
Returns
this logger, for chaining

Definition at line 388 of file Log.hpp.


The documentation for this class was generated from the following file:
  • /gfs-oceanweb/web/ocssw/ocssw_src/include/focs/Log.hpp