elsa logging¶
Table of Contents
Logger¶
-
class
elsa
::
Logger
¶ Logging class for elsa purposes (wrapper around spdlog).
This class provides logging for the elsa library. It is a thin wrapper around the spdlog third party library, using the single-threaded versions of the sinks.
- Author
Maximilian Hornung - initial version
- Author
Tobias Lasser - rewrite
Logger::get(“name”) requests a logger (from spdlog) corresponding to “name”, which is used just as you would use spdlog directly, i.e. you can use the info(), debug(), warn() etc. routines. For more details on spdlog, please visit https://github.com/gabime/spdlog.
By default, Logger enables console logging. If requested, file logging can enabled in addition via addFileSink. Log levels are set via setLevel (again, they correspond to the spdlog log levels).
Public Types
Public Static Functions
-
std::shared_ptr<spdlog::logger>
get
(std::string name)¶ return a logger corresponding to “name” (if not existing, it is created)
-
void
enableFileLogging
(std::string filename)¶ enable file logging
-
void
flush
()¶ flush all loggers
-
void
addSink
(std::ostream &os)¶ add a sink that writes to
std::ostream
(useful for testing)
Private Members
-
std::string
_fileName
= {""}¶ the file name for file logging (if enabled)
-
std::unordered_map<std::string, std::shared_ptr<spdlog::logger>>
_loggers
¶ map storing the loggers identified by a string
Private Static Functions
-
std::shared_ptr<spdlog::sinks::dist_sink_st>
initSinks
()¶ Static function initialising the sinks.
-
std::shared_ptr<spdlog::sinks::dist_sink_st>
sinks
()¶ Return the sinks stored for the loggers.
Friends
- friend class LogGuard
LogGuard¶
-
class
elsa
::
LogGuard
¶ simple log guard class, logs a message each on creation and destruction.
This class serves as a guard for logging, simple instantiation will log a starting message, while going out of scope logs an ending message.
- Author
Matthias Wieczorek - initial code
- Author
Maximilian Hornung - modularization
- Author
Tobias Lasser - minor modifications
Timer¶
-
class
elsa
::
Timer
¶ Timer class to provide easy logging of timing.
This class provides logging of timing using the guard pattern. It measures the current time from creation, until destruction and outputs a log message with time elapsed on destruction.
- Author
Matthias Wieczorek - initial code
- Author
Maximilian Hornung - modularization
- Author
Tobias Lasser - minor changes
- Author
David Frank - use spdlog::stopwatch, renaming of variables for expressing intent better