summaryrefslogtreecommitdiff
path: root/src/logger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/logger.cpp')
-rw-r--r--src/logger.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/logger.cpp b/src/logger.cpp
index 78809c555..e3e956325 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -21,7 +21,6 @@
#include "inspircd.h"
-#include "filelogger.h"
/*
* Suggested implementation...
@@ -51,7 +50,7 @@
*/
const char LogStream::LogHeader[] =
- "Log started for " INSPIRCD_VERSION " (" INSPIRCD_REVISION ", " MODULE_INIT_STR ")"
+ "Log started for " INSPIRCD_VERSION " (" MODULE_INIT_STR ")"
" - compiled on " INSPIRCD_SYSTEM;
LogManager::LogManager()
@@ -121,7 +120,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<unsigned int>(tag->getInt("flush", 20, 1, INT_MAX)));
logmap.insert(std::make_pair(target, fw));
}
else
@@ -208,10 +207,9 @@ void LogManager::DelLogStream(LogStream* l)
{
for (std::map<std::string, std::vector<LogStream*> >::iterator i = LogStreams.begin(); i != LogStreams.end(); ++i)
{
- std::vector<LogStream*>::iterator it;
- while ((it = std::find(i->second.begin(), i->second.end(), l)) != i->second.end())
+ while (stdalgo::erase(i->second, l))
{
- i->second.erase(it);
+ // Keep erasing while it exists
}
}
@@ -237,11 +235,8 @@ bool LogManager::DelLogType(const std::string &type, LogStream *l)
if (i != LogStreams.end())
{
- std::vector<LogStream *>::iterator it = std::find(i->second.begin(), i->second.end(), l);
-
- if (it != i->second.end())
+ if (stdalgo::erase(i->second, l))
{
- i->second.erase(it);
if (i->second.size() == 0)
{
LogStreams.erase(i);
@@ -293,7 +288,7 @@ void LogManager::Log(const std::string &type, LogLevel loglevel, const std::stri
for (std::map<LogStream *, std::vector<std::string> >::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;
}
@@ -314,8 +309,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)
{
}
@@ -327,7 +324,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);
}