Chat-Room 1
A chatroom with multithreaded server & client based on TCP/IP sockets, using boost::asio library in C++.
Public Types | Public Member Functions | Protected Attributes | List of all members
Logger Class Reference

A class for logging messages to different locations such as text files or databases. More...

#include <Logger.h>

Public Types

enum  Location { DISABLED , TEXT_FILE , DATABASE }
 Enum representing the possible logging locations. More...
 

Public Member Functions

 Logger ()
 Default constructor that initializes the logger with logging disabled.
 
 Logger (const Location &loc)
 Constructor that initializes the logger with the specified logging location. More...
 
 Logger (const std::string &fileName, const Location &loc)
 Constructor that initializes the logger with a file name and logging location. More...
 
 Logger (const Logger &)=delete
 Copy constructor is deleted to prevent copying of the logger.
 
 ~Logger ()
 Destructor that cleans up resources used by the logger.
 
bool log ()
 Logs an empty string. More...
 
bool log (const std::string &message)
 Logs a specific message. More...
 
bool log (const std::initializer_list< std::string > &messages)
 Logs multiple messages provided in an initializer list. More...
 

Protected Attributes

std::string m_ClassName
 The name of the class, intended for use by derived classes.
 

Detailed Description

A class for logging messages to different locations such as text files or databases.

The Logger class provides functionality to log messages to various locations depending on the configuration.

Member Enumeration Documentation

◆ Location

Enum representing the possible logging locations.

Enumerator
DISABLED 

Logging is disabled.

TEXT_FILE 

Log messages to a text file.

DATABASE 

Log messages to a database.

Constructor & Destructor Documentation

◆ Logger() [1/2]

Logger::Logger ( const Location loc)

Constructor that initializes the logger with the specified logging location.

Parameters
locThe location where logs should be written.

◆ Logger() [2/2]

Logger::Logger ( const std::string &  fileName,
const Location loc 
)

Constructor that initializes the logger with a file name and logging location.

Parameters
fileNameThe name of the file where logs will be written.
locThe location where logs should be written.

Member Function Documentation

◆ log() [1/3]

bool Logger::log ( )

Logs an empty string.

Returns
True if the log was successful, false otherwise.

◆ log() [2/3]

bool Logger::log ( const std::initializer_list< std::string > &  messages)

Logs multiple messages provided in an initializer list.

Parameters
messagesThe list of messages to be logged.
Returns
True if the log was successful, false otherwise.

◆ log() [3/3]

bool Logger::log ( const std::string &  message)

Logs a specific message.

Parameters
messageThe message to be logged.
Returns
True if the log was successful, false otherwise.

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