FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
ns_log::anonymous_namespace{log.hpp}::Logger Class Reference

Public Member Functions

 Logger ()
 Construct a new Logger:: Logger object.
 
 Logger (Logger const &)=delete
 
 Logger (Logger &&)=delete
 
Loggeroperator= (Logger const &)=delete
 
Loggeroperator= (Logger &&)=delete
 
void set_level (Level level)
 Sets the logging verbosity (CRITICAL,ERROR,INFO,DEBUG)
 
Level get_level () const
 Get current verbosity level of the logger.
 
pid_t get_pid () const
 Get the PID that was active when this logger was initialized.
 
void set_sink_file (fs::path const &path_file_sink)
 Sets the sink file of the logger.
 
void set_as_fork ()
 Marks the logger as being in a forked child process.
 
void flush ()
 Flushes the buffer content to the log file if it is defined.
 
std::ofstream & get_sink_file ()
 Gets the sink file of the logger.
 

Detailed Description

Definition at line 161 of file log.hpp.

Constructor & Destructor Documentation

◆ Logger()

ns_log::anonymous_namespace{log.hpp}::Logger::Logger ( )
inline

Construct a new Logger:: Logger object.

Definition at line 227 of file log.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ flush()

void ns_log::anonymous_namespace{log.hpp}::Logger::flush ( )
inline

Flushes the buffer content to the log file if it is defined.

Definition at line 277 of file log.hpp.

◆ get_level()

Level ns_log::anonymous_namespace{log.hpp}::Logger::get_level ( ) const
inlinenodiscard

Get current verbosity level of the logger.

Returns
Level

Definition at line 300 of file log.hpp.

◆ get_pid()

pid_t ns_log::anonymous_namespace{log.hpp}::Logger::get_pid ( ) const
inlinenodiscard

Get the PID that was active when this logger was initialized.

This returns the PID from when the Logger constructor ran, which may differ from the current PID if this is a forked child process. This enables fork detection: if getpid() != get_pid(), we're in a child process.

Returns
pid_t The original process ID (parent's PID in forked children)

Definition at line 314 of file log.hpp.

◆ get_sink_file()

std::ofstream & ns_log::anonymous_namespace{log.hpp}::Logger::get_sink_file ( )
inlinenodiscard

Gets the sink file of the logger.

Returns
std::ofstream& The reference to the sink file

Definition at line 269 of file log.hpp.

◆ set_as_fork()

void ns_log::anonymous_namespace{log.hpp}::Logger::set_as_fork ( )
inline

Marks the logger as being in a forked child process.

Sets m_pid to an invalid value (0) so that getpid() will always differ from it. This ensures log messages always display the current PID instead of file location information, making it clear these logs come from a separate child process.

Definition at line 327 of file log.hpp.

◆ set_level()

void ns_log::anonymous_namespace{log.hpp}::Logger::set_level ( Level level)
inline

Sets the logging verbosity (CRITICAL,ERROR,INFO,DEBUG)

Parameters
levelEnumeration of the verbosity level

Definition at line 290 of file log.hpp.

◆ set_sink_file()

void ns_log::anonymous_namespace{log.hpp}::Logger::set_sink_file ( fs::path const & path_file_sink)
inline

Sets the sink file of the logger.

Parameters
path_file_sinkThe path to the logger sink file

Definition at line 245 of file log.hpp.


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