summaryrefslogtreecommitdiff
path: root/src/helperfuncs.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-09 13:19:41 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-09 13:19:41 +0000
commit54546ce8b8ca863eb3f4024094cf012500d68683 (patch)
treee54d257c1441af07ab9d075fadabd84f66bed557 /src/helperfuncs.cpp
parent09afa5085614e0224a296abd082fce205003c3fe (diff)
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
Diffstat (limited to 'src/helperfuncs.cpp')
-rw-r--r--src/helperfuncs.cpp28
1 files changed, 15 insertions, 13 deletions
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());
}
}