Limo
A simple mod manager
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <filesystem>
8#include <functional>
9#include <string>
10
11
15namespace Log
16{
19{
20 LOG_ERROR = 0,
21 LOG_WARNING = 1,
22 LOG_INFO = 2,
23 LOG_DEBUG = 3
24};
25
30inline LogLevel log_level = LOG_INFO;
32inline std::vector<std::function<void(std::string, LogLevel)>> log_printers;
34inline std::filesystem::path log_dir = "";
36inline std::filesystem::path log_file_path = "";
38inline int num_log_files = 10;
39
45void init(std::filesystem::path log_dir_path = "");
51void debug(const std::string& message, int target_printer = 0);
57void info(const std::string& message, int target_printer = 0);
63void warning(const std::string& message, int target_printer = 0);
69void error(const std::string& message, int target_printer = 0);
76void log(LogLevel level, const std::string& message, int target_printer = 0);
77}
Contains functions for logging.
Definition log.cpp:58
LogLevel
Represents the importance of a log message.
Definition log.h:19
int num_log_files
Numberof log files to keep. One file is written per init() call.
Definition log.h:38
LogLevel log_level
Current log level. Messages with a log level less important than this will be ignored.
Definition log.h:30
void info(const std::string &message, int target_printer)
Prints the current time and date followed by an info message.
Definition log.cpp:69
std::vector< std::function< void(std::string, LogLevel)> > log_printers
Callback function used to output log messages.
Definition log.h:32
void log(LogLevel level, const std::string &message, int target_printer)
Calls the appropriate logging function for the given log level with the given message.
Definition log.cpp:79
std::filesystem::path log_file_path
Path to a log file. If this is != "" and exists, the log will be appended to that file.
Definition log.h:36
std::filesystem::path log_dir
Directory to which log files should be written. Empty string means no log files.
Definition log.h:34
void error(const std::string &message, int target_printer)
Prints the current time and date followed by an error message.
Definition log.cpp:59
void debug(const std::string &message, int target_printer)
Prints the current time and date followed by a debug message.
Definition log.cpp:74
void warning(const std::string &message, int target_printer)
Prints the current time and date followed by a warning message.
Definition log.cpp:64