Limo
A simple mod manager
Loading...
Searching...
No Matches
Log Namespace Reference

Contains functions for logging. More...

Enumerations

enum  LogLevel { LOG_ERROR = 0 , LOG_WARNING = 1 , LOG_INFO = 2 , LOG_DEBUG = 3 }
 Represents the importance of a log message.
 

Functions

void error (const std::string &message, int target_printer=0)
 Prints the current time and date followed by an error message.
 
void warning (const std::string &message, int target_printer=0)
 Prints the current time and date followed by a warning message.
 
void info (const std::string &message, int target_printer=0)
 Prints the current time and date followed by an info message.
 
void debug (const std::string &message, int target_printer=0)
 Prints the current time and date followed by a debug message.
 
void log (LogLevel level, const std::string &message, int target_printer=0)
 Calls the appropriate logging function for the given log level with the given message.
 
void init (sfs::path log_dir_path)
 
void init (std::filesystem::path log_dir_path="")
 init Initializes the logger by setting the current log_file_path and renaming or deleting old log files if needed.
 

Variables

LogLevel log_level = LOG_INFO
 Current log level. Messages with a log level less important than this will be ignored.
 
std::vector< std::function< void(std::string, LogLevel)> > log_printers
 Callback function used to output log messages.
 
std::filesystem::path log_dir = ""
 Directory to which log files should be written. Empty string means no log files.
 
std::filesystem::path log_file_path = ""
 Path to a log file. If this is != "" and exists, the log will be appended to that file.
 
int num_log_files = 10
 Numberof log files to keep. One file is written per init() call.
 

Detailed Description

Contains functions for logging.

Function Documentation

◆ debug()

void Log::debug ( const std::string & message,
int target_printer = 0 )

Prints the current time and date followed by a debug message.

Parameters
messageMessage to be printed.
target_printerLog printer to use for output.

◆ error()

void Log::error ( const std::string & message,
int target_printer = 0 )

Prints the current time and date followed by an error message.

Parameters
messageMessage to be printed.
target_printerLog printer to use for output.

◆ info()

void Log::info ( const std::string & message,
int target_printer = 0 )

Prints the current time and date followed by an info message.

Parameters
messageMessage to be printed.
target_printerLog printer to use for output.

◆ init()

void Log::init ( std::filesystem::path log_dir_path = "")

init Initializes the logger by setting the current log_file_path and renaming or deleting old log files if needed.

Parameters
log_dir_pathPath to the logging directory.

◆ log()

void Log::log ( LogLevel level,
const std::string & message,
int target_printer = 0 )

Calls the appropriate logging function for the given log level with the given message.

Parameters
levelLog level for the message.
messageMessage to be printed.
target_printerLog printer to use for output.

◆ warning()

void Log::warning ( const std::string & message,
int target_printer = 0 )

Prints the current time and date followed by a warning message.

Parameters
messageMessage to be printed.
target_printerLog printer to use for output.