#include <logfactory.h>
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. | |
BotKernel * | kernel |
Stores a kernel pointerr. |
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.
LogFactory::LogFactory | ( | BotKernel * | b | ) |
Constructor.
Constructor
Definition at line 34 of file logfactory.cpp.
References Plugin::addRequirement(), Plugin::author, Plugin::bindFunction(), Plugin::description, BotKernel::getDatasDir(), BotKernel::getSysLog(), IN_COMMAND_HANDLER, IN_LOOP, IN_TYPE_HANDLER, kernel, LogFile::log(), logs, Plugin::name, OUT_ALL_MSGS, Plugin::version, and WARNING.
LogFactory::~LogFactory | ( | ) |
Destructor.
Destructor
Definition at line 68 of file logfactory.cpp.
References destroyLogs(), and logs.
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
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
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
channel | Channel to test |
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
channel | Channel where the event occured | |
event | Event to log |
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
channel | Channel to log |
Definition at line 173 of file logfactory.cpp.
References BotKernel::getDatasDir(), kernel, logs, and LogFile::open().
Referenced by log().
BotKernel* LogFactory::kernel [private] |
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().