]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/logger.cpp
Move ugly .*.inc files into make/template/ where they can be more easily found
[user/henk/code/inspircd.git] / src / logger.cpp
index e2baa4b8da4137b0434579b8b8a68a40a77865ad..19e07e78f64188b5b08e2724ced28d08f853409d 100644 (file)
@@ -11,8 +11,6 @@
  * ---------------------------------------------------
  */
 
-/* $Core */
-
 #include "inspircd.h"
 
 #include "filelogger.h"
  *
  */
 
+LogManager::LogManager()
+{
+       noforkstream = NULL;
+       Logging = false;
+}
+
+LogManager::~LogManager()
+{
+       if (noforkstream)
+       {
+               ServerInstance->Logs = this;
+               delete noforkstream;
+               ServerInstance->Logs = NULL;
+       }
+}
+
 void LogManager::SetupNoFork()
 {
        if (!noforkstream)
@@ -70,18 +84,21 @@ void LogManager::OpenFileLogs()
        {
                return;
        }
-       ConfigReader* Conf = new ConfigReader;
+       ConfigReader Conf;
        std::map<std::string, FileWriter*> logmap;
        std::map<std::string, FileWriter*>::iterator i;
-       for (int index = 0; index < Conf->Enumerate("log"); ++index)
+       for (int index = 0;; ++index)
        {
-               std::string method = Conf->ReadValue("log", "method", index);
+               ConfigTag* tag = ServerInstance->Config->ConfValue("log", index);
+               if (!tag)
+                       break;
+               std::string method = tag->getString("method");
                if (method != "file")
                {
                        continue;
                }
-               std::string type = Conf->ReadValue("log", "type", index);
-               std::string level = Conf->ReadValue("log", "level", index);
+               std::string type = tag->getString("type");
+               std::string level = tag->getString("level");
                int loglevel = DEFAULT;
                if (level == "debug" || ServerInstance->Config->forcedebug)
                {
@@ -105,7 +122,7 @@ void LogManager::OpenFileLogs()
                        loglevel = NONE;
                }
                FileWriter* fw;
-               std::string target = Conf->ReadValue("log", "target", index);
+               std::string target = Conf.ReadValue("log", "target", index);
                if ((i = logmap.find(target)) == logmap.end())
                {
                        FILE* f = fopen(target.c_str(), "a");