]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/logger.h
Patch by dz avoiding <badchan:redirect> loops, and tidying up on-rehash checks.
[user/henk/code/inspircd.git] / include / logger.h
index c4729035cdaa8f08f57db3f148e5aad7844fcf1d..121d9ff252415e6cf2857c82bdf74e8c0e9999bb 100644 (file)
@@ -86,7 +86,9 @@ class CoreExport LogStream : public classbase
 
        virtual ~LogStream() { }
 
-       virtual void OnLog(int loglevel, const std::string &type, const std::string &msg) { }
+       void ChangeLevel(int lvl) { this->loglvl = lvl; } // For on-the-fly change of loglevel.
+
+       virtual void OnLog(int loglevel, const std::string &type, const std::string &msg) = 0;
 };
 
 typedef std::map<FileWriter*, int> FileLogMap;
@@ -95,8 +97,10 @@ class CoreExport LogManager : public classbase
 {
  private:
        bool Logging; // true when logging, avoids recursion
+       LogStream* noforkstream; // LogStream for nofork.
        InspIRCd *ServerInstance;
        std::map<std::string, std::vector<LogStream *> > LogStreams;
+       std::map<LogStream *, int> AllLogStreams; // holds all logstreams
        std::vector<LogStream *> GlobalLogStreams; //holds all logstreams with a type of *
        FileLogMap FileLogs; /* Holds all file logs, refcounted */
  public:
@@ -106,6 +110,8 @@ class CoreExport LogManager : public classbase
                Logging = false;
        }
 
+       void SetupNoFork();
+
        void AddLoggerRef(FileWriter* fw)
        {
                FileLogMap::iterator i = FileLogs.find(fw);
@@ -133,7 +139,8 @@ class CoreExport LogManager : public classbase
        void OpenSingleFile(FILE* f, const std::string& type, int loglevel);
        void OpenFileLogs();
        void CloseLogs();
-       bool AddLogType(const std::string &type, LogStream *l);
+       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, ...);