Changeset 375 for cpp/frams/loggers/loggers.cpp
- Timestamp:
- 04/26/15 00:59:09 (8 years ago)
- Location:
- cpp/frams/loggers
- Files:
-
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/loggers/loggers.cpp
r374 r375 3 3 // See LICENSE.txt for details. 4 4 5 #include " mhandlers.h"5 #include "loggers.h" 6 6 #include <common/stl-util.h> 7 7 8 void _ HmessageSingleLine(const char *o, const char *m, const char *txt, int w)8 void _logMessageSingleLine(const char *o, const char *m, int w, const char *txt) 9 9 { 10 tlsGetRef(message_handler_manager_instance).send(o, m, txt, w);10 tlsGetRef(message_handler_manager_instance).send(o, m, w, txt); 11 11 } 12 12 13 THREAD_LOCAL_DEF( MessageHandlerManager, message_handler_manager_instance);13 THREAD_LOCAL_DEF(LoggerManager, message_handler_manager_instance); 14 14 15 void MessageHandlerManager::send(int level, const char *o, const char *m, const char *bl, int w)15 void LoggerManager::send(int level, const char *o, const char *m, int w, const char *bl) 16 16 { 17 17 if (level >= handlers.size()) level = handlers.size() - 1; … … 19 19 for (int i = level; i >= 0; i--) 20 20 { 21 MessageHandlerBase *r = handlers(i);22 if ((!(r->options & MessageHandlerBase::Paused)) &&23 ((!blocked) || (r->options & MessageHandlerBase::CannotBeBlocked)))21 LoggerBase *r = handlers(i); 22 if ((!(r->options & LoggerBase::Paused)) && 23 ((!blocked) || (r->options & LoggerBase::CannotBeBlocked))) 24 24 { 25 r->handle(o, m, bl, w);26 if (!(r->options & MessageHandlerBase::DontBlock)) blocked = 1;25 r->handle(o, m, w, bl); 26 if (!(r->options & LoggerBase::DontBlock)) blocked = 1; 27 27 } 28 28 } 29 29 } 30 30 31 int MessageHandlerManager::add(MessageHandlerBase *h)31 int LoggerManager::add(LoggerBase *h) 32 32 { 33 33 h->manager = this; … … 36 36 } 37 37 38 void MessageHandlerManager::remove(int i)38 void LoggerManager::remove(int i) 39 39 { 40 MessageHandlerBase *h = handlers(i);40 LoggerBase *h = handlers(i); 41 41 h->manager = NULL; 42 42 handlers.remove(i); 43 43 } 44 44 45 void MessageHandlerManager::remove(MessageHandlerBase *h)45 void LoggerManager::remove(LoggerBase *h) 46 46 { 47 47 int i; … … 50 50 } 51 51 52 void MessageHandlerManager::removeAll()52 void LoggerManager::removeAll() 53 53 { 54 54 while (handlers.size() > 0) … … 58 58 ////////////////////////////////// 59 59 60 void MessageHandlerBase::send(const char *o, const char *m, const char *bl, int w)60 void LoggerBase::send(const char *o, const char *m, int w, const char *bl) 61 61 { 62 62 if (!isEnabled()) return; 63 63 int level = manager->find(this); 64 if (level >= 0) manager->send(level - 1, o, m, bl, w);64 if (level >= 0) manager->send(level - 1, o, m, w, bl); 65 65 } 66 66 67 void MessageHandlerBase::Hprintf(const char *o, const char *m, int w, const char *bl, ...)67 void LoggerBase::logPrintf(const char *o, const char *m, int w, const char *bl, ...) 68 68 { 69 69 if (!isEnabled()) return; … … 73 73 buf = ssprintf_va(bl, argptr); 74 74 va_end(argptr); 75 send(o, m, buf.c_str(), w);75 send(o, m, w, buf.c_str()); 76 76 } 77 77 78 78 79 void MessageHandlerBase::enable()79 void LoggerBase::enable() 80 80 { 81 81 if (isEnabled()) return; … … 83 83 } 84 84 85 void MessageHandlerBase::disable()85 void LoggerBase::disable() 86 86 { 87 87 if (!isEnabled()) return; … … 89 89 } 90 90 91 void MessageHandlerBase::pause()91 void LoggerBase::pause() 92 92 { 93 93 if (isPaused()) return; … … 95 95 } 96 96 97 void MessageHandlerBase::resume()97 void LoggerBase::resume() 98 98 { 99 99 if (!isPaused()) return; … … 103 103 ///////////////////////////////// 104 104 105 void MessageHandlerToMemory::handle(const char *o, const char *m, const char *bl, int w)105 void LoggerToMemory::handle(const char *o, const char *m, int w, const char *bl) 106 106 { 107 107 if (w > maxlevel) maxlevel = w; 108 if (w >= HMLV_INFO) infocount++;109 if (w >= HMLV_WARN) warncount++;110 if (w >= HMLV_ERROR) errcount++;108 if (w >= LOG_INFO) infocount++; 109 if (w >= LOG_WARN) warncount++; 110 if (w >= LOG_ERROR) errcount++; 111 111 112 112 if (w >= minleveltostore) … … 118 118 { 119 119 if (msgs.len() > 0) msgs += '\n'; 120 msgs += o; msgs += "::"; msgs += m; 121 msgs += " - "; msgs += bl; 120 msgs += SString::sprintf(LOG_FORMAT,LOG_LEVEL[w+1],o,m,bl); 122 121 } 123 122 }
Note: See TracChangeset
for help on using the changeset viewer.