X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Flogger.cpp;h=6fa972c739228621579a4c3ef5e9bd74ac9337fa;hb=57e4bf97250a20f0b54957f2d5aabf02f158c171;hp=61f1eb17990d11bcd91d7c72135663306390425e;hpb=fbc73e20784b055485f676096e758d6aeed62e0c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/logger.cpp b/src/logger.cpp index 61f1eb179..6fa972c73 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -50,8 +50,7 @@ */ const char LogStream::LogHeader[] = - "Log started for " INSPIRCD_VERSION " (" INSPIRCD_REVISION ", " MODULE_INIT_STR ")" - " - compiled on " INSPIRCD_SYSTEM; + "Log started for " INSPIRCD_VERSION " (" MODULE_INIT_STR ")"; LogManager::LogManager() : Logging(false) @@ -120,7 +119,7 @@ void LogManager::OpenFileLogs() struct tm *mytime = gmtime(&time); strftime(realtarget, sizeof(realtarget), target.c_str(), mytime); FILE* f = fopen(realtarget, "a"); - fw = new FileWriter(f); + fw = new FileWriter(f, static_cast(tag->getInt("flush", 20, 1, INT_MAX))); logmap.insert(std::make_pair(target, fw)); } else @@ -288,7 +287,7 @@ void LogManager::Log(const std::string &type, LogLevel loglevel, const std::stri for (std::map >::iterator gi = GlobalLogStreams.begin(); gi != GlobalLogStreams.end(); ++gi) { - if (std::find(gi->second.begin(), gi->second.end(), type) != gi->second.end()) + if (stdalgo::isin(gi->second, type)) { continue; } @@ -309,8 +308,10 @@ void LogManager::Log(const std::string &type, LogLevel loglevel, const std::stri } -FileWriter::FileWriter(FILE* logfile) -: log(logfile), writeops(0) +FileWriter::FileWriter(FILE* logfile, unsigned int flushcount) + : log(logfile) + , flush(flushcount) + , writeops(0) { } @@ -322,7 +323,7 @@ void FileWriter::WriteLogLine(const std::string &line) // throw CoreException("FileWriter::WriteLogLine called with a closed logfile"); fputs(line.c_str(), log); - if (++writeops % 20 == 0) + if (++writeops % flush == 0) { fflush(log); }