LogFactory Class Reference

This plugin manage channels logging. More...

#include <logfactory.h>

Inheritance diagram for LogFactory:

Plugin

List of all members.

Public Member Functions

 LogFactory (BotKernel *)
 Constructor.
 ~LogFactory ()
 Destructor.
bool hasToBeLogged (string)
 Tell if a given channel has to be logged.
vector< Channel * > getLoggedChannels ()
 Return logged channels.
void destroyLogs ()
 Destroy logs.
void cleanLogs ()
 clean logs
bool newLog (string)
 Open a new log for a channel.
void closeLog (string)
 Clode and delete a log.
bool log (string, string)
 Log an event in a LogFile object.

Private Attributes

map< string, LogFile * > * logs
 Map that sotred LogFile objects.
BotKernelkernel
 Stores a kernel pointerr.


Detailed Description

This plugin manage channels logging.

This plugin manage channels logging. It uses LogFile class provided by the kernel. LogFiles are stored in datas directory.

Definition at line 45 of file logfactory.h.


Constructor & Destructor Documentation

LogFactory::LogFactory ( BotKernel b  ) 

LogFactory::~LogFactory (  ) 

Destructor.

Destructor

Definition at line 68 of file logfactory.cpp.

References destroyLogs(), and logs.


Member Function Documentation

void LogFactory::cleanLogs (  ) 

clean logs

As configuration can change during process, a log file can be still openned while it has not to be logged anymore. This method will close log where the bot is no more present, or that have not to be logged anymore. Case : the bot join a channel, a log file is openned. Then the configuration change, and the channel has no more to be logged. The bot leave the channel. As it's no more in configuration file, the file is not closed. This method will ensure that no useless logs are openned. Call it in a timer.

Definition at line 123 of file logfactory.cpp.

References closeLog(), BotKernel::getPlugin(), UsersInfos::getUsers(), hasToBeLogged(), Tools::isInVector(), kernel, logs, and pPlugin::object.

void LogFactory::closeLog ( string  channel  ) 

Clode and delete a log.

Close a log and delete its object

Parameters:
channel Channel for witch we close log

Definition at line 183 of file logfactory.cpp.

References LogFile::close(), and logs.

Referenced by cleanLogs().

void LogFactory::destroyLogs (  ) 

Destroy logs.

Destroy log files

Definition at line 77 of file logfactory.cpp.

References logs.

Referenced by ~LogFactory().

vector< Channel * > LogFactory::getLoggedChannels (  ) 

Return logged channels.

Return channels that are logged and where the bot is present

Returns:
A vector containg a pointer on Channel objects

Definition at line 97 of file logfactory.cpp.

References BotKernel::getCONFF(), BotKernel::getPlugin(), UsersInfos::getUsers(), ConfigurationFile::getValue(), kernel, Plugin::name, pPlugin::object, and Tools::stringToVector().

bool LogFactory::hasToBeLogged ( string  channel  ) 

Tell if a given channel has to be logged.

Tell if a given channel has to be logged

Parameters:
channel Channel to test
Returns:
true if the channel has to be logged, else false

Definition at line 88 of file logfactory.cpp.

References BotKernel::getCONFF(), ConfigurationFile::getValue(), Tools::isInVector(), kernel, Plugin::name, and Tools::stringToVector().

Referenced by cleanLogs().

bool LogFactory::log ( string  channel,
string  event 
)

Log an event in a LogFile object.

Log an event in a logfile. If the log file is not opened, this function will try to do it

Parameters:
channel Channel where the event occured
event Event to log
Returns:
true if event has been logged

Definition at line 155 of file logfactory.cpp.

References LogFile::log(), logs, and newLog().

bool LogFactory::newLog ( string  channel  ) 

Open a new log for a channel.

Open a new log for a channel and store it

Parameters:
channel Channel to log
Returns:
true is the log file has been opened, else false

Definition at line 173 of file logfactory.cpp.

References BotKernel::getDatasDir(), kernel, logs, and LogFile::open().

Referenced by log().


Member Data Documentation

Stores a kernel pointerr.

Definition at line 51 of file logfactory.h.

Referenced by cleanLogs(), getLoggedChannels(), hasToBeLogged(), LogFactory(), and newLog().

map<string,LogFile*>* LogFactory::logs [private]

Map that sotred LogFile objects.

Definition at line 49 of file logfactory.h.

Referenced by cleanLogs(), closeLog(), destroyLogs(), log(), LogFactory(), newLog(), and ~LogFactory().


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

Generated on Sun Aug 16 15:28:47 2009 for trustyRC by  doxygen 1.5.8