]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Last of the -Wshadow fixes.
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 3f60cac80419acc443aab3e34f4bef9fe4bc03e8..8e9f4dfd5c8c6289d732f6b60a97f19f38e28cfd 100644 (file)
 #include "xline.h"
 #include "exitcodes.h"
 
-static char TIMESTR[26];
-static time_t LAST = 0;
-
 /** Log()
  *  Write a line of text `text' to the logfile (and stdout, if in nofork) if the level `level'
  *  is greater than the configured loglevel.
  */
 void InspIRCd::Log(int level, const char* text, ...)
 {
-       /* sanity check, just in case */
-       if (!this->Config || !this->Logger)
-               return;
-
-       /* Do this check again here so that we save pointless vsnprintf calls */
-       if ((level < Config->LogLevel) && !Config->forcedebug)
-               return;
-
        va_list argsPtr;
        char textbuffer[65536];
 
@@ -47,34 +36,8 @@ void InspIRCd::Log(int level, const char* text, ...)
 
 void InspIRCd::Log(int level, const std::string &text)
 {
-       /* sanity check, just in case */
-       if (!this->Config || !this->Logger)
-               return;
-
-       /* If we were given -debug we output all messages, regardless of configured loglevel */
-       if ((level < Config->LogLevel) && !Config->forcedebug)
-               return;
-
-       if (Time() != LAST)
-       {
-               time_t local = Time();
-               struct tm *timeinfo = localtime(&local);
-
-               strlcpy(TIMESTR,asctime(timeinfo),26);
-               TIMESTR[24] = ':';
-               LAST = Time();
-       }
-
-       if (Config->log_file && Config->writelog)
-       {
-               std::string out = std::string(TIMESTR) + " " + text.c_str() + "\n";
-               this->Logger->WriteLogLine(out);
-       }
-
-       if (Config->nofork)
-       {
-               printf("%s %s\n", TIMESTR, text.c_str());
-       }
+       this->Logs->Log("WARNING", DEFAULT, "Deprecated call to InspIRCd::Log()! - log message follows");
+       this->Logs->Log("DEPRECATED", level, text);
 }
 
 std::string InspIRCd::GetServerDescription(const char* servername)
@@ -358,11 +321,13 @@ bool InspIRCd::OpenLog(char**, int)
 
        if (!Config->log_file)
        {
-               this->Logger = NULL;
                return false;
        }
 
-       this->Logger = new FileLogger(this, Config->log_file);
+       FileWriter* fw = new FileWriter(this, Config->log_file);
+       FileLogStream *f = new FileLogStream(this, Config->LogLevel, fw);
+
+       this->Logs->AddLogType("*", f);
        return true;
 }
 
@@ -451,19 +416,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;