Elaztek Developer Hub
Blamite Game Engine - Strings  00390.07.02.23.1947.blamite
A library containing general purpose utilities and classes for use in multiple projects.
BlamBasicLogger Class Reference

Class representing a basic logger. More...

#include <logger.h>

Public Member Functions

 BlamBasicLogger ()
 Initializes a new logger. More...
 
 BlamBasicLogger (int _unique_id)
 Initializes a new logger with a unique ID. More...
 
 BlamBasicLogger (int _unique_id, std::string _save_directory, std::string _log_name)
 Initializes a new logger with a unique ID. More...
 
void ClearHistory (std::string _save_directory="", std::string _file_name="")
 Clears all log history. More...
 
void SetCommandLinePrintingEnabled (bool print_to_cmd)
 Sets whether or not log messages should be written to the standard output. More...
 
std::vector< BlamBasicLogMessageGetHistory ()
 Retrieves the log history. More...
 
void LogEvent (BlamBasicLogMessage message)
 Writes a message to the log. More...
 
void LogEvent (std::string message)
 Writes a message to the log. More...
 
void LogEvent (std::string message, BlamLogLevel log_level)
 Writes a message to the log. More...
 
void LogEvent (std::string message, TerminalColor color)
 Writes a message to the log. More...
 
void AddReceiver (BlamLogReceiver *receiver)
 Registers a receiver to this logger. More...
 
void RemoveReceiver (BlamLogReceiver *receiver)
 Unregisters a receiver from this logger. More...
 
bool WriteToFile (std::string directory_path="", std::string file_name="log")
 Saves the log history to the specified directory. More...
 

Detailed Description

Class representing a basic logger.

In order to avoid having multiple applications implement their own logging systems, they can instead use one of these. This logger provides basic logging functionality. It does not organize log messages into reports, so the engine itself wouldn't be able to use one of these. But many of the editing tools do not require the use of reports, so all that is needed is a simple log.

Constructor & Destructor Documentation

◆ BlamBasicLogger() [1/3]

BlamBasicLogger::BlamBasicLogger ( )

Initializes a new logger.

+ Here is the call graph for this function:

◆ BlamBasicLogger() [2/3]

BlamBasicLogger::BlamBasicLogger ( int  _unique_id)

Initializes a new logger with a unique ID.

Parameters
_unique_id- The ID to give to the logger, can be used to determine where log messages originate.

◆ BlamBasicLogger() [3/3]

BlamBasicLogger::BlamBasicLogger ( int  _unique_id,
std::string  _save_directory,
std::string  _log_name 
)

Initializes a new logger with a unique ID.

Parameters
_unique_id- The ID to give to the logger, can be used to determine where log messages originate.
_save_directory- The default directory to save the log file contents to.
_log_name- The default filename for the log file.

Member Function Documentation

◆ AddReceiver()

void BlamBasicLogger::AddReceiver ( BlamLogReceiver receiver)

Registers a receiver to this logger.

The receiver will be notified whenever a new log message is received.

Parameters
receiver- The receiver to add.
+ Here is the caller graph for this function:

◆ ClearHistory()

void BlamBasicLogger::ClearHistory ( std::string  _save_directory = "",
std::string  _file_name = "" 
)

Clears all log history.

Cannot be undone.

+ Here is the call graph for this function:

◆ GetHistory()

std::vector< BlamBasicLogMessage > BlamBasicLogger::GetHistory ( )

Retrieves the log history.

Returns
The log history.
+ Here is the caller graph for this function:

◆ LogEvent() [1/4]

void BlamBasicLogger::LogEvent ( BlamBasicLogMessage  message)

Writes a message to the log.

Parameters
message- The new message to log.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LogEvent() [2/4]

void BlamBasicLogger::LogEvent ( std::string  message)

Writes a message to the log.

Parameters
message- The new message to log.
+ Here is the call graph for this function:

◆ LogEvent() [3/4]

void BlamBasicLogger::LogEvent ( std::string  message,
BlamLogLevel  log_level 
)

Writes a message to the log.

Parameters
message- The new message to log.
log_level- The log level of the message.
+ Here is the call graph for this function:

◆ LogEvent() [4/4]

void BlamBasicLogger::LogEvent ( std::string  message,
TerminalColor  color 
)

Writes a message to the log.

Parameters
message- The new message to log.
color- The color to use when printing the message to the standard output.
+ Here is the call graph for this function:

◆ RemoveReceiver()

void BlamBasicLogger::RemoveReceiver ( BlamLogReceiver receiver)

Unregisters a receiver from this logger.

The receiver will no longer be notified whenever a new log message is received.

Parameters
receiver- The receiver to remove.
+ Here is the caller graph for this function:

◆ SetCommandLinePrintingEnabled()

void BlamBasicLogger::SetCommandLinePrintingEnabled ( bool  print_to_cmd)

Sets whether or not log messages should be written to the standard output.

Parameters
print_to_cmd- Whether or not to print messages to stdout.

◆ WriteToFile()

bool BlamBasicLogger::WriteToFile ( std::string  directory_path = "",
std::string  file_name = "log" 
)

Saves the log history to the specified directory.

Parameters
directory_path- The directory to store the log file in. If left blank, then the default directory is used. If this is left blank AND no directory has been specified, then the log file will not be written and this method will fail.
file_name- The prefix/name for the log file. Defaults to log. This should usually be customized depending on the application which is saving the log file.
Returns
true if the log file was saved successfully, otherwise returns false.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: