Logger v1.0.0
Custom cli console for creating commands executable at runtime
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
lg::Log Class Reference

Log manages logging with levels and timestamps. More...

#include <logger.hpp>

Public Types

enum class  LogLevel {
  info = 0x01 , warning = 0x02 , error = 0x04 , debug = 0x08 ,
  memory = 0x10
}
 Enum specifying the log level.
 

Public Member Functions

void operator() (LogLevel level, std::string text)
 Prints out a log with a set log level.
 
void operator() (std::string text)
 Prints out a log with a default log level of info.
 
void SetLevel (short log_level)
 Sets the levels that are supposed to be displayed.
 

Detailed Description

Log manages logging with levels and timestamps.

Log should not be created by the user, the library exposes it as in inline variable log. It is responsible for filtering logs based on their level and creating threads that safely put logs on the screen.

Member Function Documentation

◆ operator()() [1/2]

void lg::Log::operator() ( LogLevel  level,
std::string  text 
)

Prints out a log with a set log level.

Firstly checks if the log level is supposed to be printed, then to avoid freezing the main thread creates a new one to print the log message.

Parameters
levellog level to print on
textlog message
Here is the caller graph for this function:

◆ operator()() [2/2]

void lg::Log::operator() ( std::string  text)

Prints out a log with a default log level of info.

Firstly checks if the log level is supposed to be printed, then to avoid freezing the main thread creates a new one to print the log message.

Parameters
textlog message
Here is the call graph for this function:

◆ SetLevel()

void lg::Log::SetLevel ( short  log_level)

Sets the levels that are supposed to be displayed.

By default thats all levels, set the levels from enum class lg::Log::LogLevel, casting them to short and or'ing them with |

Parameters
log_levellog levels to show

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