From 3897856fb7d887883f7b3c61143ce0b256c00ff8 Mon Sep 17 00:00:00 2001 From: w00t Date: Sat, 9 Feb 2008 11:35:27 +0000 Subject: Initial totally untested logger implementation that does nothing. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8856 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/logger.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'src') diff --git a/src/logger.cpp b/src/logger.cpp index 690c1a5d9..458dcf5e0 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -41,3 +41,69 @@ * can we accomplish this easily? I guess with a map of pre-loved logpaths, and a pointer of FILE *.. * */ + +bool LogManager::AddLogType(const std::string &type, LogStream *l) +{ + std::map >::iterator i = LogStreams.find(type); + + if (i != LogStreams.end()) + i->second.push_back(l); + else + { + std::vector v; + v.push_back(l); + LogStreams[type] = v; + } + + return true; +} + +bool LogManager::DelLogType(const std::string &type, LogStream *l) +{ + std::map >::iterator i = LogStreams.find(type); + + if (i != LogStreams.end()) + { + std::vector::iterator it = i->second.begin(); + + while (it != i->second.end()) + { + if (*it == l) + { + i->second.erase(it); + + if (i->second.size() == 0) + { + LogStreams.erase(i); + } + + delete l; + return true; + } + } + } + + return false; +} + +void LogManager::Log(const std::string &type, int loglevel, const std::string &msg) +{ + std::map >::iterator i = LogStreams.find(type); + + if (i != LogStreams.end()) + { + std::vector::iterator it = i->second.begin(); + + while (it != i->second.end()) + { + (*it)->OnLog(loglevel, msg); + } + + return; + } + + // blurp, no handler for this type + return; +} + + -- cgit v1.2.3