From af7e1a1ca8b36064593becf62b1a91468ad32237 Mon Sep 17 00:00:00 2001 From: w00t Date: Sat, 9 Feb 2008 12:41:17 +0000 Subject: New logging implementation. Also write messages about InspIRCd::Log() being deprecated. Any takers on changing it all to use the new system? :P. STILL TODO: create blocks in config, add a method called to 'cleanup' (or use destructor) of logstreams, add a method to logmanager to initiate destruction of all logstreams. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8858 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/helperfuncs.cpp | 45 ++++----------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) (limited to 'src/helperfuncs.cpp') diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 3f60cac80..d274dd244 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -18,23 +18,12 @@ #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,11 @@ bool InspIRCd::OpenLog(char**, int) if (!Config->log_file) { - this->Logger = NULL; return false; } - this->Logger = new FileLogger(this, Config->log_file); + FileLogStream *f = new FileLogStream(this, Config->log_file, "*"); + this->Logs->AddLogType("*", f); return true; } -- cgit v1.2.3