logger
logger.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <string>
10 
11 #include "line.hpp"
12 #include "logger_export.hpp"
13 #include "output.hpp"
14 
18 namespace logger
19 {
20  // public interface
21 
26  bool LOGGER_EXPORT enabled();
31  Level LOGGER_EXPORT consoleLevel();
36  Level LOGGER_EXPORT fileLevel();
41  std::string LOGGER_EXPORT logFile();
42 
49  void LOGGER_EXPORT enable(const Level & consoleLevel = Info, const Level & fileLevel = Off, const std::string & logFileFormat = "log/%Y-%m-%d-%H-%M-%S.txt");
53  void LOGGER_EXPORT disable();
54 
59  int LOGGER_EXPORT contextLength();
64  void LOGGER_EXPORT setContextLength(const int & contextLength);
69  bool LOGGER_EXPORT printTime();
74  void LOGGER_EXPORT setPrintTime(const bool & printTime);
79  std::string LOGGER_EXPORT timeFormat();
84  void LOGGER_EXPORT setTimeFormat(const std::string & timeFormat);
85 
91  Line LOGGER_EXPORT verbose(const std::string & context = "");
97  Line LOGGER_EXPORT debug(const std::string & context = "");
103  Line LOGGER_EXPORT info(const std::string & context = "");
109  Line LOGGER_EXPORT warning(const std::string & context = "");
115  Line LOGGER_EXPORT error(const std::string & context = "");
116 }
Level fileLevel()
Gets the minimum Level for file output.
std::string logFile()
Gets the output file for file logging.
Line warning(const std::string &context="")
Creates a new Line object with the Level Info. Once this object is destroyed, the content will be sen...
Level
Levels for filtering messages based on importance.
Definition: level.hpp:16
Used for disabling outputs.
Definition: level.hpp:41
int contextLength()
Gets the context lenght.
void setContextLength(const int &contextLength)
Sets the context lenght.
bool printTime()
Checks whether the current time is included in output.
void setPrintTime(const bool &printTime)
Sets whether the current time should be included in output.
void disable()
Disables the logger.
Line class.
Logger namespace. Contains all available functions and classes.
Definition: level.hpp:11
Line error(const std::string &context="")
Creates a new Line object with the Level Error. Once this object is destroyed, the content will be se...
Used for important information. When logging to console, messages with this level will be sent to cou...
Definition: level.hpp:29
void enable(const Level &consoleLevel=Info, const Level &fileLevel=Off, const std::string &logFileFormat="log/%Y-%m-%d-%H-%M-%S.txt")
Enables the logger with the given minimum Levels. Call again to change these settings. This results in a new log file being generated, if file logging is enabled.
void setTimeFormat(const std::string &timeFormat)
Sets the format used printing the time.
std::string timeFormat()
Gets the format used printing the time.
Level consoleLevel()
Gets the minimum Level for console output.
bool enabled()
Checks if the logger is enabled.
Line verbose(const std::string &context="")
Creates a new Line object with the Level Verbose. Once this object is destroyed, the content will be ...
Line debug(const std::string &context="")
Creates a new Line object with the Level Debug. Once this object is destroyed, the content will be se...
Line info(const std::string &context="")
Creates a new Line object with the Level Info. Once this object is destroyed, the content will be sen...