*
*/
+void LogManager::CloseLogs()
+{
+ /*
+ * This doesn't remove logstreams from the map/vector etc, because if this is called, shit is hitting the fan
+ * and we're going down anyway - this just provides a "nice" way for logstreams to clean up. -- w
+ */
+ std::map<std::string, std::vector<LogStream *> >::iterator i;
+
+ while (LogStreams.begin() != LogStreams.end())
+ {
+ i = LogStreams.begin();
+
+ while (i->second.begin() != i->second.end())
+ {
+ std::vector<LogStream *>::iterator it = i->second.begin();
+
+ delete (*it);
+ i->second.erase(it);
+ }
+
+ LogStreams.erase(i);
+ }
+}
+
bool LogManager::AddLogType(const std::string &type, LogStream *l)
{
std::map<std::string, std::vector<LogStream *> >::iterator i = LogStreams.find(type);
void LogManager::Log(const std::string &type, int loglevel, const char *fmt, ...)
{
+ if (Logging)
+ return;
+
va_list a;
- char buf[65536];
+ static char buf[65536];
va_start(a, fmt);
vsnprintf(buf, 65536, fmt, a);
void LogManager::Log(const std::string &type, int loglevel, const std::string &msg)
{
+ if (Logging)
+ return;
+
+ Logging = true;
+
+ std::vector<LogStream *>::iterator gi = GlobalLogStreams.begin();
+
+ while (gi != GlobalLogStreams.end())
+ {
+ (*gi)->OnLog(loglevel, type, msg);
+ gi++;
+ }
+
std::map<std::string, std::vector<LogStream *> >::iterator i = LogStreams.find(type);
if (i != LogStreams.end())
while (it != i->second.end())
{
- (*it)->OnLog(loglevel, msg);
+ (*it)->OnLog(loglevel, type, msg);
it++;
}
-
- return;
- }
-
- std::vector<LogStream *>::iterator gi = GlobalLogStreams.begin();
-
- while (gi != GlobalLogStreams.end())
- {
- (*gi)->OnLog(loglevel, msg);
- gi++;
}
- // blurp, no handler for this type
- return;
+ Logging = false;
}