A simple, delphi compatible, Logging Unit.
Simply add the uLogger.pas
Unit from the src
directory to your project's source files. Below are two examples of how
to use this Logger.
program logtest;
uses uLogger;
var
logger: TLogger;
begin
logger := TLogger.Create;
logger.Log(<LOG_LEVEL_CONSTANT>, 'Log Message');
logger.LogF(<LOG_LEVEL_COSTANT>, '%s Log Message', ['Formatted']);
end.
program logtest;
uses uLogger;
var
logger: TLogger;
begin
logger := TLogger.Create('LogFile.log');
logger.Log(<LOG_LEVEL_CONSTANT>, 'Log Message');
logger.LogF(<LOG_LEVEL_COSTANT>, '%s Log Message', ['Formatted']);
logger.Free; // The log is written to file when free is called
end.
Debug Message: LOG_LVL_DBG
Notification: LOG_LVL_NOTICE
Information Message: LOG_LVL_INF
Warning Message: LOG_LVL_WARN
Error Message: LOG_LVL_ERR
Fatality Message: LOGL_LVL_FATAL
On creation, the default Format-Settings are copied to be used by the logger. The Format Settings of the Logger are stored in the FLoggerFormatSettings
variable an can be modified.
Silent mode can be toggled by modifying the FSilent
field. If the logger is in silent mode, it will only write to its Log file (if set up).