InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Public Member Functions | List of all members
LogManager Class Reference

Public Member Functions

void AddLoggerRef (FileWriter *fw)
 
void DelLoggerRef (FileWriter *fw)
 
void OpenFileLogs ()
 
void CloseLogs ()
 
void AddLogTypes (const std::string &type, LogStream *l, bool autoclose)
 
bool AddLogType (const std::string &type, LogStream *l, bool autoclose)
 
void DelLogStream (LogStream *l)
 
bool DelLogType (const std::string &type, LogStream *l)
 
void Log (const std::string &type, int loglevel, const std::string &msg)
 
void Log (const std::string &type, int loglevel, const char *fmt,...) CUSTOM_PRINTF(4
 

Member Function Documentation

void LogManager::AddLoggerRef ( FileWriter fw)
inline

Adds a FileWriter instance to LogManager, or increments the reference count of an existing instance. Used for file-stream sharing for FileLogStreams.

bool LogManager::AddLogType ( const std::string &  type,
LogStream l,
bool  autoclose 
)

Registers a new logstream into the logging core, so it can be called for future events It is not a good idea to mix values of autoclose for the same LogStream.

Parameters
typeThe type to add this LogStream to.
lThe LogStream to add.
autocloseTrue to have the LogStream automatically closed when all references to it are removed from LogManager. False to leave it open.
Returns
True if the LogStream was added successfully, False otherwise.
void LogManager::AddLogTypes ( const std::string &  type,
LogStream l,
bool  autoclose 
)

Adds a single LogStream to multiple logtypes. This automatically handles things like "* -USERINPUT -USEROUTPUT" to mean all but USERINPUT and USEROUTPUT types. It is not a good idea to mix values of autoclose for the same LogStream.

Parameters
typeThe type string (from configuration, or whatever) to parse.
lThe LogStream to add.
autocloseTrue to have the LogStream automatically closed when all references to it are removed from LogManager. False to leave it open.
void LogManager::CloseLogs ( )

Removes all LogStreams, meaning they have to be readded for logging to continue. Only LogStreams that were listed in AllLogStreams are actually closed.

void LogManager::DelLoggerRef ( FileWriter fw)
inline

Indicates that a FileWriter reference has been removed. Reference count is decreased, and if zeroed, the FileWriter is closed.

void LogManager::DelLogStream ( LogStream l)

Removes a logstream from the core. After removal, it will not recieve further events. If the LogStream was ever added with autoclose, it will be closed after this call (this means the pointer won't be valid anymore).

bool LogManager::DelLogType ( const std::string &  type,
LogStream l 
)

Removes a LogStream from a single type. If the LogStream has been registered for "*" it will still receive the type unless you remove it from "*" specifically. If the LogStream was added with autoclose set to true, then when the last occurrence of the stream is removed it will automatically be closed (freed).

void LogManager::Log ( const std::string &  type,
int  loglevel,
const std::string &  msg 
)

Logs an event, sending it to all LogStreams registered for the type.

Parameters
typeLog message type (ex: "USERINPUT", "MODULE", ...)
loglevelLog message level (DEBUG, VERBOSE, DEFAULT, SPARSE, NONE)
msgThe message to be logged (literal).
void LogManager::Log ( const std::string &  type,
int  loglevel,
const char *  fmt,
  ... 
)

Logs an event, sending it to all LogStreams registered for the type.

Parameters
typeLog message type (ex: "USERINPUT", "MODULE", ...)
loglevelLog message level (DEBUG, VERBOSE, DEFAULT, SPARSE, NONE)
fmtThe format of the message to be logged. See your C manual on printf() for details.
void LogManager::OpenFileLogs ( )

Opens all logfiles defined in the configuration file using <log method="file">.


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