Logger

class Logger

A singleton threaded logger class. Logs to stdout and a logfile with timestamps and varying levels of severity. Non-blocking and high performant.

Subclassed by AppLogger::TrajectoryLogger

Public Functions

Logger(Logger const&) = delete

No copy constructor allowed.

void operator=(Logger const&) = delete

No assignment operator allowed.

Public Static Functions

static inline bool Log(const std::string &value, SEVERITY level = SEVERITY::INFO)

Log a message to stdout and the log file.

Parameters:
  • value – The string to log.

  • level – The severity of the message, defaults to INFO.

Returns:

static inline void SetVerbosity(SEVERITY verbosity)

Set the minimum verbosity of logging messages to be recorded. Defaults to INFO.

Parameters:

verbosity – The verbosity.

static inline void SetStdout(bool enabled)

Enable or disable logging to stdout.

Parameters:

enabled – Enable stdout logging if true, disable if false.

static inline bool GetStdout()

Check if logging to stdout.

Returns:

true if logging to stdout, false otherwise.

static inline void SetFileout(bool enabled)

Enable or disable logging to the logfile.

Parameters:

enabled – Enable logfile logging if true, disable if false.

static inline bool GetFileout()

Check if logfile output is enabled.

Returns:

logfile logging if true, no logfile logging if false.

static inline std::string GetFilePath()

Get the logging file path.

Returns:

The path to the logging file relative to the directory the main executable was started from.

static inline void SetFilepath(const std::string &filepath)

Set the logging file path.

Parameters:

filepath – The path to the logging file relative to the directory the main executable was started from.

static inline Logger &GetInstance()

Get the singleton logger instance. If no instance exists, create a new static instance.

Returns:

The singleton logger instance.

static inline bool Flush()

Flush stdout and fstream. Block until the operation completes.

Returns:

true if all data was successfully flushed, false if not.

static inline bool Close(bool terminate = false)

Stop the logger.

Parameters:

terminate – If terminate=true forcefully stop the logger without flushing messages, otherwise gracefully stop the logger and allow the messages to be flushed.

Returns:

true if all data was successfully flushed, false otherwise.