1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
18 #include "socketengine.h"
19 #include "filelogger.h"
21 FileLogStream::FileLogStream(int loglevel, FileWriter *fw)
22 : LogStream(loglevel), f(fw)
24 ServerInstance->Logs->AddLoggerRef(f);
27 FileLogStream::~FileLogStream()
29 /* FileWriter is managed externally now */
30 ServerInstance->Logs->DelLoggerRef(f);
33 void FileLogStream::OnLog(int loglevel, const std::string &type, const std::string &text)
35 static char TIMESTR[26];
36 static time_t LAST = 0;
38 if (loglevel < this->loglvl)
43 if (ServerInstance->Time() != LAST)
45 time_t local = ServerInstance->Time();
46 struct tm *timeinfo = localtime(&local);
48 strlcpy(TIMESTR,asctime(timeinfo),26);
50 LAST = ServerInstance->Time();
53 std::string out = std::string(TIMESTR) + " " + text.c_str() + "\n";
54 this->f->WriteLogLine(out);