From 54546ce8b8ca863eb3f4024094cf012500d68683 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 9 Aug 2006 13:19:41 +0000 Subject: do_log -> static void InspIRCd::Log() (with vararg and std::string variants) The #define for this still exists, but maybe should be phased out? git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4809 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/helperfuncs.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/helperfuncs.cpp') diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index b25370df6..97cb68f33 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -65,11 +65,20 @@ static time_t LAST = 0; * 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 do_log(int level, const char *text, ...) +void InspIRCd::Log(int level, const char* text, ...) { va_list argsPtr; char textbuffer[MAXBUF]; + va_start(argsPtr, text); + vsnprintf(textbuffer, MAXBUF, text, argsPtr); + va_end(argsPtr); + + InspIRCd::Log(level, std::string(textbuffer)); +} + +void InspIRCd::Log(int level, const std::string &text) +{ if (!ServerInstance || !ServerInstance->Config) return; @@ -86,22 +95,15 @@ void do_log(int level, const char *text, ...) LAST = TIME; } - if (ServerInstance->Config->log_file) + if (ServerInstance->Config->log_file && ServerInstance->Config->writelog) { - va_start(argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - - if (ServerInstance->Config->writelog) - { - fprintf(ServerInstance->Config->log_file,"%s %s\n",TIMESTR,textbuffer); - fflush(ServerInstance->Config->log_file); - } + fprintf(ServerInstance->Config->log_file,"%s %s\n",TIMESTR,text.c_str()); + fflush(ServerInstance->Config->log_file); } - + if (ServerInstance->Config->nofork) { - printf("%s %s\n", TIMESTR, textbuffer); + printf("%s %s\n", TIMESTR, text.c_str()); } } -- cgit v1.3.1-10-gc9f91