1: 
   2: 
   3: /**********************
   4: *                     *
   5: *  COMPILER INCLUDES  *
   6: *                     *
   7: **********************/
   8: 
   9: 
  10: #include <syslog.h> 
  11: #include "wwwi/singleton.h" 
  12: 
  13: 
  14: using WWWI::GetSingleton; 
  15: 
  16: 
  17: /*********************
  18: *                    *
  19: *  METHOD SETMETHOD  *
  20: *                    *
  21: *********************/
  22: 
  23: 
  24: inline void MINDLog::SetMethod(LogMethod i_lm) {
  25:   m_lm = i_lm;
  26:   if (i_lm==LM_SYSLOG) {
  27:     openlog("mnamed",LOG_PID,LOG_DAEMON);
  28:   }
  29: }
  30: 
  31: 
  32: 
  33: /************************
  34: *                       *
  35: *  METHODS SETPRIORITY  *
  36: *                       *
  37: ************************/
  38: 
  39: 
  40: inline void MINDLog::SetPriority(LogPriority i_lyAll) {
  41:   unsigned u;
  42:   for(u=0;u<LF_MAX;u++) {
  43:     this->SetPriority((LogFacility)u,i_lyAll);      
  44:   }
  45: }
  46: 
  47: 
  48: inline void MINDLog::SetPriority(LogFacility i_lf, LogPriority i_ly) {
  49:   m_lya[i_lf] = i_ly;
  50: }
  51: 
  52: 
  53: /*********************
  54: *                    *
  55: *  METHOD SETSTREAM  *
  56: *                    *
  57: *********************/
  58: 
  59: 
  60: inline void MINDLog::SetStream(ostream *i_smp) { m_smp = i_smp; }
  61: 
  62: 
  63: /*********************
  64: *                    *
  65: *  METHOD SYSLOGPRI  *
  66: *                    *
  67: *********************/
  68: 
  69: 
  70: inline int MINDLog::SyslogPri(LogPriority i_ly) {
  71:   switch(i_ly) {
  72:   case LY_EXTRA_DEBUG: return LOG_DEBUG;
  73:   case LY_DEBUG: return LOG_DEBUG;
  74:   case LY_INFO: return LOG_INFO;
  75:   case LY_ERROR: return LOG_ERR;
  76:   case LY_FAILURE: return LOG_CRIT;
  77:   }
  78:   return LOG_ERR;
  79: }
  80: 
  81: 
  82: /********************
  83: *                   *
  84: *  METHOD WOULDLOG  *
  85: *                   *
  86: ********************/
  87: 
  88: 
  89: inline bool MINDLog::WouldLog(LogFacility i_lf, LogPriority i_ly) {
  90:   return (m_lya[i_lf]<=i_ly);
  91: }
  92: 
  93: 
  94: /*********************
  95: *                    *
  96: *  FUNCTION FASTLOG  *
  97: *                    *
  98: *********************/
  99: 
 100: 
 101: inline void FastLog(LogFacility i_lf, LogPriority i_ly, const char *i_strMessage) {
 102:   MINDLogPtr lgp = GetSingleton<MINDLog>();
 103:   if (lgp->WouldLog(i_lf,i_ly)==false) return;
 104:   lgp->Log(i_lf,i_ly,i_strMessage);
 105: }
 106: 
 107: 
 108: