Manticore  Version 1.0
Physics of Molecular Clouds
Static Public Member Functions | Static Public Attributes | List of all members
mutils::Log Struct Reference

Logging facility. More...

#include <mutils/Log.h>

Static Public Member Functions

template<typename... Args>
static int debug (Args &&... args)
 Logs a message at level DEBUG. More...
 
template<typename... Args>
static int error (Args &&... args)
 Logs a message at level ERROR. More...
 
template<typename... Args>
static int info (Args &&... args)
 Logs a message at level INFO. More...
 
template<typename... Args>
static int message (int lev, Args &&... args)
 Logs a message. More...
 
static const char * name (int lev=mutils::Log::level)
 Standard logging level name string. More...
 
static void setLevel (const std::string &str)
 Sets logging level from name string. More...
 
static int setStream (const std::string &fname, bool append=true)
 Sets the logging stream. More...
 
template<typename... Args>
static int warn (Args &&... args)
 Logs a message at level WARN. More...
 

Static Public Attributes

static constexpr int DEBUG = 3
 Verbose information. More...
 
static constexpr int ERROR = 0
 Error condition. More...
 
static std::string file = "!"
 Message log file name. More...
 
static constexpr int INFO = 2
 Informational message. More...
 
static int level = Log::WARN
 Message logging level for output to stream. More...
 
static FILE * stream = stderr
 Message log file stream. More...
 
static constexpr int WARN = 1
 Warning condition. More...
 

Detailed Description

Logging facility.

Supports the generation and use of log messages. Defined messaging levels:

Level Name Indication Expectation
0 ERROR error condition fatal, execution terminates
1 WARN warning condition recoverable, execution at risk
2 INFO informational execution not at risk
3 DEBUG verbose information normal execution

Definition at line 344 of file Log.h.

Member Function Documentation

◆ debug()

template<typename... Args>
static int mutils::Log::debug ( Args &&...  args)
inlinestatic

Logs a message at level DEBUG.

Parameters
[in]argsArguments for cxxfprintf() (not including the stream).

Definition at line 426 of file Log.h.

References DEBUG, and message().

◆ error()

template<typename... Args>
static int mutils::Log::error ( Args &&...  args)
inlinestatic

Logs a message at level ERROR.

Parameters
[in]argsArguments for cxxfprintf() (not including the stream).

Definition at line 408 of file Log.h.

References ERROR, and message().

◆ info()

template<typename... Args>
static int mutils::Log::info ( Args &&...  args)
inlinestatic

Logs a message at level INFO.

Parameters
[in]argsArguments for cxxfprintf() (not including the stream).

Definition at line 420 of file Log.h.

References INFO, and message().

◆ message()

template<typename... Args>
static int mutils::Log::message ( int  lev,
Args &&...  args 
)
inlinestatic

Logs a message.

Logs a message to stream if lev is less than or equal to level. The args are passed verbatim to cxxfprintf().

Parameters
[in]levMinimum log level required to print message.
[in]argsArguments for cxxfprintf() (not including the stream).
Returns
Number of characters written.

Definition at line 402 of file Log.h.

References mutils::cxxfprintf(), level, and stream.

Referenced by debug(), error(), info(), and warn().

◆ name()

static const char* mutils::Log::name ( int  lev = mutils::Log::level)
inlinestatic

Standard logging level name string.

Parameters
[in]levMessage level (default: current logging level).
Returns
Logging level name string.

Definition at line 355 of file Log.h.

References ERROR, INFO, and WARN.

Referenced by mutils::Exception::message(), and setLevel().

◆ setLevel()

static void mutils::Log::setLevel ( const std::string &  str)
inlinestatic

Sets logging level from name string.

Parameters
[in]strStandard logging level name string.
Note
If str is not recognized, the level is not changed.
See also
name()

Definition at line 368 of file Log.h.

References DEBUG, ERROR, level, and name().

◆ setStream()

static int mutils::Log::setStream ( const std::string &  fname,
bool  append = true 
)
inlinestatic

Sets the logging stream.

Parameters
[in]fnameLog file name ("-" is stdout, "!" is stderr).
[in]appendWhether to append to existing files (else overwrite).
Returns
Zero on success, else -1.
Note
If the new file cannot be opened, the existing stream is retained.

Definition at line 380 of file Log.h.

References mutils::cxxfclose(), mutils::cxxfopen(), file, and stream.

Referenced by main().

◆ warn()

template<typename... Args>
static int mutils::Log::warn ( Args &&...  args)
inlinestatic

Logs a message at level WARN.

Parameters
[in]argsArguments for cxxfprintf() (not including the stream).

Definition at line 414 of file Log.h.

References message(), and WARN.

Member Data Documentation

◆ DEBUG

constexpr int mutils::Log::DEBUG = 3
static

Verbose information.

Definition at line 350 of file Log.h.

Referenced by debug(), setLevel(), and mutils::CommandLine::usage().

◆ ERROR

constexpr int mutils::Log::ERROR = 0
static

Error condition.

Definition at line 347 of file Log.h.

Referenced by error(), name(), and setLevel().

◆ file

std::string mutils::Log::file = "!"
static

Message log file name.

Definition at line 436 of file Log.h.

Referenced by mutils::exitException(), and setStream().

◆ INFO

constexpr int mutils::Log::INFO = 2
static

Informational message.

Definition at line 349 of file Log.h.

Referenced by info(), and name().

◆ level

int mutils::Log::level = Log::WARN
static

Message logging level for output to stream.

Definition at line 430 of file Log.h.

Referenced by main(), message(), mutils::Exception::print(), setLevel(), and mutils::CommandLine::usage().

◆ stream

FILE * mutils::Log::stream = stderr
static

Message log file stream.

Definition at line 433 of file Log.h.

Referenced by manticore::ccfCheck(), main(), message(), mutils::Exception::print(), manticore::printVersion(), and setStream().

◆ WARN

constexpr int mutils::Log::WARN = 1
static

Warning condition.

Definition at line 348 of file Log.h.

Referenced by main(), name(), and warn().


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