-#include "commands.h"
-#include "inspstring.h"
-#include "helperfuncs.h"
-#include "hashcomp.h"
-#include "typedefs.h"
-#include "inspircd.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, ...)
-{
- 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)
-{
- extern InspIRCd* ServerInstance;
-
- if (!ServerInstance || !ServerInstance->Config)
- return;
-
- /* If we were given -debug we output all messages, regardless of configured loglevel */
- if ((level < ServerInstance->Config->LogLevel) && !ServerInstance->Config->forcedebug)
- return;
-
- if (ServerInstance->Time() != LAST)
- {
- time_t local = ServerInstance->Time();
- struct tm *timeinfo = localtime(&local);
-
- strlcpy(TIMESTR,asctime(timeinfo),26);
- TIMESTR[24] = ':';
- LAST = ServerInstance->Time();
- }
-
- if (ServerInstance->Config->log_file && ServerInstance->Config->writelog)
- {
- 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, text.c_str());
- }
-}