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
Private Members
-
std::unique_ptr<std::string>
_fileName
= {}¶ the file name for file logging (if enabled)
-
std::map<std::string, std::shared_ptr<spdlog::logger>>
_loggers
¶ map storing the loggers identified by a string
Private Static Functions
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¶
-
template<class
Duration
= std::chrono::milliseconds, classClock
= std::chrono::steady_clock>
classelsa
::
Timer
¶ Timer class to provide easy logging of timing.
This class provides logging of timing using the guard pattern. It stores the current time upon creation, and outputs a log message with time elapsed on destruction.
- Author
Matthias Wieczorek - initial code
- Author
Maximilian Hornung - modularization
- Author
Tobias Lasser - minor changes