2008-01-17 12:02:22 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
|
|
|
* InspIRCd: (C) 2002-2008 InspIRCd Development Team
|
|
|
|
* See: http://www.inspircd.org/wiki/index.php/Credits
|
|
|
|
*
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2008-02-09 11:35:27 +00:00
|
|
|
#ifndef __LOGMANAGER_H
|
|
|
|
#define __LOGMANAGER_H
|
|
|
|
|
|
|
|
class CoreExport LogStream : public classbase
|
|
|
|
{
|
2008-02-09 12:41:17 +00:00
|
|
|
protected:
|
2008-02-09 11:35:27 +00:00
|
|
|
InspIRCd *ServerInstance;
|
2008-02-10 14:20:58 +00:00
|
|
|
int loglvl;
|
2008-02-09 11:35:27 +00:00
|
|
|
public:
|
2008-02-10 14:20:58 +00:00
|
|
|
LogStream(InspIRCd *Instance, int loglevel) : loglvl(loglevel)
|
2008-02-09 11:35:27 +00:00
|
|
|
{
|
|
|
|
this->ServerInstance = Instance;
|
|
|
|
}
|
|
|
|
|
2008-02-09 21:00:07 +00:00
|
|
|
virtual void OnLog(int loglevel, const std::string &type, const std::string &msg) { }
|
2008-02-09 11:35:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CoreExport LogManager : public classbase
|
|
|
|
{
|
|
|
|
private:
|
2008-02-09 21:00:07 +00:00
|
|
|
bool Logging; // true when logging, avoids recursion
|
2008-02-09 11:35:27 +00:00
|
|
|
InspIRCd *ServerInstance;
|
|
|
|
std::map<std::string, std::vector<LogStream *> > LogStreams;
|
2008-02-09 12:41:17 +00:00
|
|
|
std::vector<LogStream *> GlobalLogStreams; //holds all logstreams with a type of *
|
2008-02-09 11:35:27 +00:00
|
|
|
public:
|
|
|
|
LogManager(InspIRCd *Instance)
|
|
|
|
{
|
|
|
|
ServerInstance = Instance;
|
2008-02-09 21:00:07 +00:00
|
|
|
Logging = false;
|
2008-02-09 11:35:27 +00:00
|
|
|
}
|
|
|
|
|
2008-02-09 20:15:09 +00:00
|
|
|
void CloseLogs();
|
2008-02-09 11:35:27 +00:00
|
|
|
bool AddLogType(const std::string &type, LogStream *l);
|
|
|
|
bool DelLogType(const std::string &type, LogStream *l);
|
|
|
|
void Log(const std::string &type, int loglevel, const std::string &msg);
|
2008-02-09 13:06:02 +00:00
|
|
|
void Log(const std::string &type, int loglevel, const char *fmt, ...);
|
2008-02-09 11:35:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|