AUI Framework
develop
Cross-platform base for C++ UI apps
|
A logger class. More...
#include <AUI/Logging/ALogger.h>
Classes | |
struct | LogWriter |
Public Types | |
enum | Level { INFO , WARN , ERR , DEBUG } |
Public Member Functions | |
ALogger (AString filename) | |
Constructor for an extra log file. | |
void | setDebugMode (bool debug) |
bool | isDebug () |
void | setLogFile (APath path) |
Sets log file. | |
APath | logFile () |
void | onLogged (std::function< void(const AString &prefix, const AString &message, Level level)> callback) |
template<aui::invocable Callable> | |
void | doLogFileAccessSafe (Callable action) |
Allows to perform some action (access safely) on log file (which is opened all over the execution process) | |
LogWriter | log (Level level, const AString &prefix) |
Writer a log entry with LogWriter helper. | |
Static Public Member Functions | |
static ALogger & | global () |
static void | setLogFileForGlobal (APath path) |
Sets log file for ALogger::global() . | |
static LogWriter | info (const AString &str) |
static LogWriter | warn (const AString &str) |
static LogWriter | err (const AString &str) |
static LogWriter | debug (const AString &str) |
A logger class.
Logger is used for journaling application events like errors or some user actions.
It provides some extra functions like logging to file and output formatting.
It provides std::cout
-like API.
Example:
Possible output:
It's convenient to define LOG_TAG
variable for your class:
|
inline |
Constructor for an extra log file.
filename | file name |
For the global logger, use ALogger::info, ALogger::warn, etc...
|
inline |
Allows to perform some action (access safely) on log file (which is opened all over the execution process)
Useful when sending log file to remote server.
Writer a log entry with LogWriter helper.
level | level |
prefix | prefix |
|
inline |
Sets log file.
path | path to the log file. |
Log file is opened immediately in setLogFile.
ALogger::global().setLogFile(...)
expression would cause the default log file location to open and to close immediately, when opening a log file in the specified location, causing empty file and two Log file:
entries.
|
static |
Sets log file for ALogger::global()
.
path | path to the log file. |