]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Crash fixes from nenolod
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index d325b40aacb03237530ccf0718da40e59cc4bf16..465f55d6f9e0ede43da0438b8d9a0e7d99f4f3b8 100644 (file)
@@ -36,8 +36,7 @@ void InspIRCd::Log(int level, const char* text, ...)
 
 void InspIRCd::Log(int level, const std::string &text)
 {
-       this->Logs->Log("WARNING", DEFAULT, "Deprecated call to InspIRCd::Log()! - log message follows");
-       this->Logs->Log("DEPRECATED", level, text);
+       this->Logs->Log("DEPRECATED", level, "Deprecated use of InspIRCd::Log(), message = %s", text.c_str());
 }
 
 std::string InspIRCd::GetServerDescription(const char* servername)
@@ -303,6 +302,12 @@ bool InspIRCd::IsSID(const std::string &str)
 /* open the proper logfile */
 bool InspIRCd::OpenLog(char**, int)
 {
+       /* This function only happens at startup now (log reopening is done at OnReadConfig stage now instead of rehash) */
+       if (Config->nofork)
+       {
+               this->Logs->SetupNoFork();
+       }
+       if (!Config->writelog) return true; // Skip opening default log if -nolog
        Config->MyDir = Config->GetFullProgDir();
 
        if (!*this->LogFileName)
@@ -325,9 +330,10 @@ bool InspIRCd::OpenLog(char**, int)
        }
 
        FileWriter* fw = new FileWriter(this, Config->log_file);
-       FileLogStream *f = new FileLogStream(this, Config->LogLevel, fw);
+       FileLogStream *f = new FileLogStream(this, (Config->forcedebug ? DEBUG : Config->LogLevel), fw);
+
+       this->Logs->AddLogType("*", f, true);
 
-       this->Logs->AddLogType("*", f);
        return true;
 }
 
@@ -336,7 +342,7 @@ void InspIRCd::CheckRoot()
        if (geteuid() == 0)
        {
                printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n");
-               this->Log(DEFAULT,"Cant start as root");
+               this->Logs->Log("STARTUP",DEFAULT,"Cant start as root");
                Exit(EXIT_STATUS_ROOT);
        }
 }
@@ -346,7 +352,7 @@ void InspIRCd::CheckDie()
        if (*Config->DieValue)
        {
                printf("WARNING: %s\n\n",Config->DieValue);
-               this->Log(DEFAULT,"Died because of <die> tag: %s",Config->DieValue);
+               this->Logs->Log("CONFIG",DEFAULT,"Died because of <die> tag: %s",Config->DieValue);
                Exit(EXIT_STATUS_DIETAG);
        }
 }
@@ -416,19 +422,19 @@ long InspIRCd::Duration(const std::string &str)
        return total + subtotal;
 }
 
-bool InspIRCd::ULine(const char* server)
+bool InspIRCd::ULine(const char* sserver)
 {
-       if (!server)
+       if (!sserver)
                return false;
-       if (!*server)
+       if (!*sserver)
                return true;
 
-       return (Config->ulines.find(server) != Config->ulines.end());
+       return (Config->ulines.find(sserver) != Config->ulines.end());
 }
 
-bool InspIRCd::SilentULine(const char* server)
+bool InspIRCd::SilentULine(const char* sserver)
 {
-       std::map<irc::string,bool>::iterator n = Config->ulines.find(server);
+       std::map<irc::string,bool>::iterator n = Config->ulines.find(sserver);
        if (n != Config->ulines.end())
                return n->second;
        else return false;