Skip to content

Logging

Functions

Close Log Process

Ensures propper memory clean-up prior to exit, if needed. Used in sk_init_looging ().

Signatures

void close_log_process()

Init Custom Logger

Init Custom Logger

Initialises the logging mode for logged messages to be written to the text-based console.

Parameters

NameTypeDescription
modeLog ModeThe mode of log output i.e. whether there should be output to the console, a text file, or both. Pass your choice of mode variable in by reference.

Signatures

void init_custom_logger(log_mode mode)

Init Custom Logger

Initialises the logging mode between either writing to a file or both a file and the text-based console.

Parameters

NameTypeDescription
app_nameStringThe name of the application being written requiring logging
override_prev_logBooleanDetermines whether or not a new logging session should override the existing file, if any. Set this to false if you want new log messages to be appended to the bottom of the file; otherwise set it to true if you would like a new file to be created on top of the old one.
modeLog ModeThe mode of log output i.e. whether there should be output to the console, a text file, or both. Pass your choice of mode variable in by reference.

Signatures

void init_custom_logger(string app_name, bool override_prev_log, log_mode mode)

Log

Send a message to the message log. The message will be written if the log level for the program is set to display this.

Parameters

NameTypeDescription
levelLog LevelThe level of the message to log
messageStringThe message to be shown

Signatures

void log(log_level level, string message)

Types

Log Level

Defines the available levels for log messages. This allows categorisation of log messages which can then be filtered allowing messages below a given level to be ignored.

ConstantValueDescription
NONEOutput to the message log but without a specified level
INFOOutput information to the message log
DEBUGOutput a debug message to the message log
WARNINGOutput a warning message to the message log
ERROROutput an error message to the message log
FATALOutput an error message to the message log

Defines the available levels for log messages. This allows categorisation of log messages which can then be filtered allowing messages below a given level to be ignored.


Log Mode

Defines the available modes of logging, indicating where messages are written to.

ConstantValueDescription
LOG_NONESet the logging mode to none for nothing to be logged to the console or a file.
LOG_CONSOLEEnsure that output only directs to the on-screen, text-based console..
LOG_FILE_ONLYEnsure that output only directs to a text file..
LOG_CONSOLE_AND_FILEDirect ouput to both the console and a file.

Defines the available modes of logging, indicating where messages are written to.