Changeset 8013c0c in nscp


Ignore:
Timestamp:
01/23/12 07:41:06 (17 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
6a30f44
Parents:
28f6a64
Message:
  • Fixed so NSCAClient parses address correctly
  • settings exception is now derived from exception meaning it will show up more with details (instead of unknown)
  • Added API for handling log level (replaces older debug flag)
  • Added options for settings debug level
  • Changed to --settings is a global argument (meaning you can use it in any mode)
  • Added arguments parsing to test: so you can use global arguments such as --log and --settings.
  • Removed memory leak in settings parsing interface
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • changelog

    rb175d61 r8013c0c  
    55 * Fixa dependonservice LanManWorkStation (old win) 
    66 * Fix RtlStringFromGUID problem on NT4 
     7 
     82012-01-22 MickeM 
     9 * Fixed so NSCAClient parses address correctly 
     10 * setings exception is now derived from exception meaning it will show up more with details (instead of unknown) 
     11 * Added API for handling log level (replaces older debug flag) 
     12 * Added options for settings debug level 
     13 * Changed to --settings is a global argument (meaning you canuse it in any mode) 
     14 * Added arguments parsing to test: so you can use global arguments such as --log and --settings. 
     15 * Removed memory leak in settings parsing interface 
    716 
    8172012-01-20 MickeM 
  • helpers/settings_manager/settings_manager_impl.cpp

    r89838be r8013c0c  
    2424  inline NSCSettingsImpl* internal_get() { 
    2525    if (settings_impl == NULL) 
    26       throw "Settings has not been initiated!"; 
     26      throw settings::settings_exception(_T("Settings has not been initiated!")); 
    2727    return settings_impl; 
    2828  } 
  • include/NSCAPI.h

    rf7a074d r8013c0c  
    9696 
    9797  // Various message Types 
    98   const int log = 1;        // Log message 
    99   const int error = -1;     // Error (non critical) 
    100   const int critical = -10;   // Critical error 
    101   const int warning = 2;      // Warning 
    102   const int debug = 10;     // Debug message 
    103  
    104   typedef int messageTypes;   // Message type 
     98  namespace log_level { 
     99    typedef int level; 
     100    const int critical = 1; // Critical error 
     101    const int error = 10; // Error 
     102    const int warning = 50; // Warning      <<< Default for command line interface 
     103    const int log = 100;  // Log message    <<< Default for service 
     104    const int info = 150; // information 
     105    const int debug = 500;  // Debug messages <<< Default for test 
     106    const int trace = 1000; // Trace messages 
     107  } 
     108 
     109  typedef log_level::level messageTypes;    // Message type 
    105110 
    106111  struct plugin_info { 
     
    175180    typedef NSCAPI::errorReturn (*lpNSAPIRegisterRoutingListener)(unsigned int plugin_id, const wchar_t* channel); 
    176181    typedef NSCAPI::errorReturn (*lpNSAPIReload)(const wchar_t* module); 
     182    typedef NSCAPI::log_level::level (*lpNSAPIGetLoglevel)(); 
    177183 
    178184  } 
  • include/nscapi/functions.hpp

    rba63b95 r8013c0c  
    118118     
    119119    static Plugin::LogEntry::Entry::Level log_to_gpb(NSCAPI::messageTypes ret) { 
    120       if (ret == NSCAPI::critical) 
     120      if (ret == NSCAPI::log_level::critical) 
    121121        return Plugin::LogEntry_Entry_Level_LOG_CRITICAL; 
    122       if (ret == NSCAPI::debug) 
     122      if (ret == NSCAPI::log_level::debug) 
    123123        return Plugin::LogEntry_Entry_Level_LOG_DEBUG; 
    124       if (ret == NSCAPI::error) 
     124      if (ret == NSCAPI::log_level::error) 
    125125        return Plugin::LogEntry_Entry_Level_LOG_ERROR; 
    126       if (ret == NSCAPI::log) 
     126      if (ret == NSCAPI::log_level::log) 
    127127        return Plugin::LogEntry_Entry_Level_LOG_INFO; 
    128       if (ret == NSCAPI::warning) 
     128      if (ret == NSCAPI::log_level::info) 
     129        return Plugin::LogEntry_Entry_Level_LOG_INFO; 
     130      if (ret == NSCAPI::log_level::warning) 
    129131        return Plugin::LogEntry_Entry_Level_LOG_WARNING; 
    130132      return Plugin::LogEntry_Entry_Level_LOG_ERROR; 
     
    132134    static NSCAPI::messageTypes gpb_to_log(Plugin::LogEntry::Entry::Level ret) { 
    133135      if (ret == Plugin::LogEntry_Entry_Level_LOG_CRITICAL) 
    134         return NSCAPI::critical; 
     136        return NSCAPI::log_level::critical; 
    135137      if (ret == Plugin::LogEntry_Entry_Level_LOG_DEBUG) 
    136         return NSCAPI::debug; 
     138        return NSCAPI::log_level::debug; 
    137139      if (ret == Plugin::LogEntry_Entry_Level_LOG_ERROR) 
    138         return NSCAPI::error; 
     140        return NSCAPI::log_level::error; 
    139141      if (ret == Plugin::LogEntry_Entry_Level_LOG_INFO) 
    140         return NSCAPI::log; 
     142        return NSCAPI::log_level::info; 
    141143      if (ret == Plugin::LogEntry_Entry_Level_LOG_WARNING) 
    142         return NSCAPI::warning; 
    143       return NSCAPI::error; 
     144        return NSCAPI::log_level::warning; 
     145      return NSCAPI::log_level::error; 
    144146    } 
    145147 
  • include/nscapi/macros.hpp

    r40fca56 r8013c0c  
    3535// Logging calls for the core wrapper  
    3636 
    37 #define NSC_LOG_ERROR_STD(msg) NSC_LOG_ERROR(((std::wstring)msg).c_str()) 
    38 #define NSC_LOG_ERROR(msg) NSC_ANY_MSG(msg,NSCAPI::error) 
     37#define NSC_LOG_ERROR_STD(msg) if (GET_CORE()->should_log(NSCAPI::log_level::error)) { NSC_ANY_MSG((std::wstring)msg, NSCAPI::log_level::error); } 
     38#define NSC_LOG_ERROR(msg) if (GET_CORE()->should_log(NSCAPI::log_level::error)) { NSC_ANY_MSG(msg, NSCAPI::log_level::error); } 
    3939 
    40 #define NSC_LOG_CRITICAL_STD(msg) NSC_LOG_CRITICAL(((std::wstring)msg).c_str()) 
    41 #define NSC_LOG_CRITICAL(msg) NSC_ANY_MSG(msg,NSCAPI::critical) 
     40#define NSC_LOG_CRITICAL_STD(msg) if (GET_CORE()->should_log(NSCAPI::log_level::critical)) { NSC_ANY_MSG((std::wstring)msg, NSCAPI::log_level::critical); } 
     41#define NSC_LOG_CRITICAL(msg) if (GET_CORE()->should_log(NSCAPI::log_level::critical)) { NSC_ANY_MSG(msg, NSCAPI::log_level::critical); } 
    4242 
    43 #define NSC_LOG_MESSAGE_STD(msg) NSC_LOG_MESSAGE(((std::wstring)msg).c_str()) 
    44 #define NSC_LOG_MESSAGE(msg) NSC_ANY_MSG(msg,NSCAPI::log) 
     43#define NSC_LOG_MESSAGE_STD(msg) if (GET_CORE()->should_log(NSCAPI::log_level::info)) { NSC_ANY_MSG((std::wstring)msg, NSCAPI::log_level::info); } 
     44#define NSC_LOG_MESSAGE(msg) if (GET_CORE()->should_log(NSCAPI::log_level::info)) { NSC_ANY_MSG(msg, NSCAPI::log_level::info); } 
    4545 
    46 #define NSC_DEBUG_MSG_STD(msg) NSC_DEBUG_MSG((std::wstring)msg) 
    47 #define NSC_DEBUG_MSG(msg) NSC_ANY_MSG(msg,NSCAPI::debug) 
     46#define NSC_DEBUG_MSG_STD(msg) if (GET_CORE()->should_log(NSCAPI::log_level::debug)) { NSC_ANY_MSG((std::wstring)msg, NSCAPI::log_level::debug); } 
     47#define NSC_DEBUG_MSG(msg) if (GET_CORE()->should_log(NSCAPI::log_level::debug)) { NSC_ANY_MSG(msg, NSCAPI::log_level::debug); } 
    4848 
    4949#define NSC_ANY_MSG(msg, type) GET_CORE()->log(type, __FILE__, __LINE__, msg) 
    50 /* 
    51 #define NSC_LOG_ERROR_STD(msg)  
    52 #define NSC_LOG_ERROR(msg)  
    53  
    54 #define NSC_LOG_CRITICAL_STD(msg)  
    55 #define NSC_LOG_CRITICAL(msg)  
    56  
    57 #define NSC_LOG_MESSAGE_STD(msg)  
    58 #define NSC_LOG_MESSAGE(msg)  
    59  
    60 #define NSC_DEBUG_MSG_STD(msg) 
    61 #define NSC_DEBUG_MSG(msg) 
    62  
    63 #define NSC_ANY_MSG(msg, type) 
    64 */ 
    6550 
    6651////////////////////////////////////////////////////////////////////////// 
  • include/nscapi/nscapi_core_wrapper.cpp

    ra87ce04 r8013c0c  
    3535using namespace nscp::helpers; 
    3636 
    37 #define CORE_LOG_ERROR_STD(msg) CORE_LOG_ERROR(((std::wstring)msg).c_str()) 
    38 #define CORE_LOG_ERROR(msg) CORE_ANY_MSG(msg,NSCAPI::error) 
    39  
    40 #define CORE_LOG_CRITICAL_STD(msg) CORE_LOG_CRITICAL(((std::wstring)msg).c_str()) 
    41 #define CORE_LOG_CRITICAL(msg) CORE_ANY_MSG(msg,NSCAPI::critical) 
    42  
    43 #define CORE_LOG_MESSAGE_STD(msg) CORE_LOG_MESSAGE(((std::wstring)msg).c_str()) 
    44 #define CORE_LOG_MESSAGE(msg) CORE_ANY_MSG(msg,NSCAPI::log) 
    45  
    46 #define CORE_DEBUG_MSG_STD(msg) CORE_DEBUG_MSG((std::wstring)msg) 
    47 #define CORE_DEBUG_MSG(msg) CORE_ANY_MSG(msg,NSCAPI::debug) 
    48  
    49 #define CORE_ANY_MSG(msg, type) log(type, __FILE__, __LINE__, msg) 
     37 
     38#define CORE_LOG_ERROR_STD(msg) if (should_log(NSCAPI::log_level::error)) { log(NSCAPI::log_level::error, __FILE__, __LINE__, (std::wstring)msg); } 
     39#define CORE_LOG_ERROR(msg) if (should_log(NSCAPI::log_level::error)) { log(NSCAPI::log_level::error, __FILE__, __LINE__, msg); } 
     40 
     41//#define CORE_LOG_CRITICAL_STD(msg) if (matches(NSCAPI::critical)) { CORE_ANY_MSG(NSCAPI::critical, __FILE__, __LINE__, (std::wstring)msg) } 
     42//#define CORE_LOG_CRITICAL(msg) if (matches(NSCAPI::critical)) { CORE_ANY_MSG(NSCAPI::critical, __FILE__, __LINE__, msg) } 
     43 
     44//#define CORE_LOG_MESSAGE_STD(msg) if (matches(NSCAPI::info)) { CORE_ANY_MSG(NSCAPI::info, __FILE__, __LINE__, (std::wstring)msg) } 
     45//#define CORE_LOG_MESSAGE(msg) if (matches(NSCAPI::info)) { CORE_ANY_MSG(NSCAPI::info, __FILE__, __LINE__, msg) } 
     46 
     47//#define CORE_DEBUG_MSG_STD(msg) if (matches(NSCAPI::debug)) { CORE_ANY_MSG(NSCAPI::debug, __FILE__, __LINE__, (std::wstring)msg) } 
     48//#define CORE_DEBUG_MSG(msg) if (matches(NSCAPI::debug)) { CORE_ANY_MSG(NSCAPI::debug, __FILE__, __LINE__, msg) } 
     49 
     50//#define CORE_ANY_MSG(msg, type) log(type, __FILE__, __LINE__, msg) 
    5051 
    5152 
     
    5354// Callbacks into the core 
    5455////////////////////////////////////////////////////////////////////////// 
     56 
     57bool nscapi::core_wrapper::should_log(NSCAPI::nagiosReturn msgType) { 
     58  enum log_status {unknown, set }; 
     59  static NSCAPI::log_level::level level = NSCAPI::log_level::log; 
     60  static log_status status = unknown; 
     61  if (status == unknown) { 
     62    level = get_loglevel(); 
     63    status = set; 
     64  } 
     65  return nscapi::logging::matches(level, msgType); 
     66} 
     67 
    5568 
    5669/** 
     
    6376 * @throws nscapi::nscapi_exception When core pointer set is unavailable. 
    6477 */ 
    65 void nscapi::core_wrapper::log(int msgType, std::string file, int line, std::wstring logMessage) { 
    66   if (fNSAPIMessage) { 
    67     if ((msgType == NSCAPI::debug) && (!logDebug())) 
    68       return; 
    69     std::string str; 
    70     try { 
    71       Plugin::LogEntry message; 
    72       Plugin::LogEntry::Entry *msg = message.add_entry(); 
    73       msg->set_level(nscapi::functions::log_to_gpb(msgType)); 
    74       msg->set_file(file); 
    75       msg->set_line(line); 
    76       msg->set_message(utf8::cvt<std::string>(logMessage)); 
    77       if (!message.SerializeToString(&str)) { 
    78         std::cout << "Failed to generate message"; 
    79       } 
    80       return fNSAPIMessage(str.c_str(), str.size()); 
    81     } catch (...) { 
    82       std::wcout << _T("Failed to generate message: "); 
     78void nscapi::core_wrapper::log(NSCAPI::nagiosReturn msgType, std::string file, int line, std::wstring logMessage) { 
     79  if (!should_log(msgType)) 
     80    return; 
     81  if (!fNSAPIMessage) { 
     82    std::wcout << _T("*** *** *** NSCore not loaded, dumping log: ") << to_wstring(file) << _T(":") << line << _T(": ") << std::endl << logMessage << std::endl; 
     83    return; 
     84  } 
     85  std::string str; 
     86  try { 
     87    Plugin::LogEntry message; 
     88    Plugin::LogEntry::Entry *msg = message.add_entry(); 
     89    msg->set_level(nscapi::functions::log_to_gpb(msgType)); 
     90    msg->set_file(file); 
     91    msg->set_line(line); 
     92    msg->set_message(utf8::cvt<std::string>(logMessage)); 
     93    if (!message.SerializeToString(&str)) { 
     94      std::wcout << _T("Failed to generate message: SERIALIZATION ERROR"); 
    8395    } 
    84 //    return fNSAPIMessage(to_string(logMessage).c_str(), logMessage.size()); 
    85   } 
    86   else 
    87     std::wcout << _T("*** *** *** NSCore not loaded, dumping log: ") << to_wstring(file) << _T(":") << line << _T(": ") << std::endl << logMessage << std::endl; 
    88 } 
    89 void nscapi::core_wrapper::log(int msgType, std::string file, int line, std::string message) { 
    90   if ((msgType == NSCAPI::debug) && (!logDebug())) 
     96    return fNSAPIMessage(str.c_str(), str.size()); 
     97  } catch (const std::exception &e) { 
     98    std::wcout << _T("Failed to generate message: ") << utf8::to_unicode(e.what()); 
     99  } catch (...) { 
     100    std::wcout << _T("Failed to generate message: UNKNOWN"); 
     101  } 
     102} 
     103void nscapi::core_wrapper::log(NSCAPI::nagiosReturn msgType, std::string file, int line, std::string message) { 
     104  if (!should_log(msgType)) 
    91105    return; 
    92106  log(msgType, file, line, utf8::cvt<std::wstring>(message)); 
    93107} 
     108 
     109NSCAPI::log_level::level nscapi::core_wrapper::get_loglevel() { 
     110  if (!fNSAPIGetLoglevel) { 
     111    return NSCAPI::log_level::debug; 
     112  } 
     113  return fNSAPIGetLoglevel(); 
     114} 
     115 
    94116 
    95117/** 
     
    237259  switch (retC) { 
    238260    case NSCAPI::returnIgnored: 
    239       CORE_LOG_MESSAGE_STD(_T("No handler for command '") + command + _T("'.")); 
     261      CORE_LOG_ERROR_STD(_T("No handler for command '") + command + _T("'.")); 
    240262      break; 
    241263    case NSCAPI::returnOK: 
     
    273295  switch (retC) { 
    274296    case NSCAPI::returnIgnored: 
    275       CORE_LOG_MESSAGE_STD(_T("No handler for command '") + command + _T("'.")); 
     297      CORE_LOG_ERROR_STD(_T("No handler for command '") + command + _T("'.")); 
    276298      break; 
    277299    case NSCAPI::returnOK: 
     
    475497} 
    476498 
    477  
    478 bool nscapi::core_wrapper::logDebug() { 
    479   enum status {unknown, debug, nodebug }; 
    480   static status d = unknown; 
    481   if (d == unknown) { 
    482     if (checkLogMessages(debug)== NSCAPI::istrue) 
    483       d = debug; 
    484     else 
    485       d = nodebug; 
    486   } 
    487   return (d == debug); 
    488 } 
    489499 
    490500std::wstring nscapi::core_wrapper::Encrypt(std::wstring str, unsigned int algorithm) { 
     
    698708  fNSAPIRegisterSubmissionListener = (nscapi::core_api::lpNSAPIRegisterSubmissionListener)f(_T("NSAPIRegisterSubmissionListener")); 
    699709  fNSAPIRegisterRoutingListener = (nscapi::core_api::lpNSAPIRegisterRoutingListener)f(_T("NSAPIRegisterRoutingListener")); 
     710  fNSAPIGetLoglevel = (nscapi::core_api::lpNSAPIGetLoglevel)f(_T("NSAPIGetLoglevel")); 
    700711 
    701712  return true; 
  • include/nscapi/nscapi_core_wrapper.hpp

    r40fca56 r8013c0c  
    7373    nscapi::core_api::lpNSAPIRegisterSubmissionListener fNSAPIRegisterSubmissionListener; 
    7474    nscapi::core_api::lpNSAPIRegisterRoutingListener fNSAPIRegisterRoutingListener; 
     75    nscapi::core_api::lpNSAPIGetLoglevel fNSAPIGetLoglevel; 
    7576 
    7677  public: 
     
    118119      , fNSAPISettingsSave(NULL) 
    119120      , fNSAPIExpandPath(NULL) 
     121      , fNSAPIGetLoglevel(NULL) 
    120122    {} 
    121123 
     
    133135    void settings_save(); 
    134136 
    135     void log(int msgType, std::string file, int line, std::wstring message); 
    136     void log(int msgType, std::string file, int line, std::string message); 
     137    void log(NSCAPI::nagiosReturn msgType, std::string file, int line, std::wstring message); 
     138    void log(NSCAPI::nagiosReturn msgType, std::string file, int line, std::string message); 
     139    bool should_log(NSCAPI::nagiosReturn msgType); 
     140    NSCAPI::log_level::level get_loglevel(); 
    137141    void DestroyBuffer(char**buffer); 
    138142    NSCAPI::nagiosReturn query(const wchar_t* command, const char *request, const unsigned int request_len, char **response, unsigned int *response_len); 
     
    153157    void Exit(void); 
    154158    std::wstring getBasePath(); 
    155     bool logDebug(); 
    156159    bool checkLogMessages(int type); 
    157160    std::wstring Encrypt(std::wstring str, unsigned int algorithm = NSCAPI::encryption_xor); 
  • include/nscapi/nscapi_helper.cpp

    r54ac968 r8013c0c  
    8585} 
    8686 
    87 #define LOG_CRIT  0x10 
    88 #define LOG_ERROR 0x08 
    89 #define LOG_WARNING 0x04 
    90 #define LOG_MSG   0x02 
    91 #define LOG_DEBUG 0x01 
    92  
    93 unsigned int nscapi::logging::parse(std::wstring str) { 
    94   unsigned int report = 0; 
     87#define PARSE_LOGLEVEL_BEGIN() if (false) {} 
     88#define PARSE_LOGLEVEL(key_str, value)  else if (*key == _T(key_str) && level < value) { level = value; } 
     89#define PARSE_LOGLEVEL_END()  
     90 
     91NSCAPI::log_level::level nscapi::logging::parse(std::wstring str) { 
     92  unsigned int level = 0; 
    9593  strEx::splitList lst = strEx::splitEx(str, _T(",")); 
    96  
    9794  for (strEx::splitList::const_iterator key = lst.begin(); key != lst.end(); ++key) { 
    98     if (*key == _T("all")) { 
    99       report |= LOG_MSG|LOG_ERROR|LOG_CRIT|LOG_WARNING|LOG_DEBUG; 
    100     } else if (*key == _T("normal")) { 
    101         report |= LOG_MSG|LOG_ERROR|LOG_CRIT|LOG_WARNING; 
    102     } else if (*key == _T("log") || *key == _T("message") || *key == _T("info") || *key == _T("INFO")) { 
    103       report |= LOG_MSG; 
    104     } else if (*key == _T("error") || *key == _T("ERROR")) { 
    105       report |= LOG_ERROR; 
    106     } else if (*key == _T("critical") || *key == _T("CRITICAL")) { 
    107       report |= LOG_CRIT; 
    108     } else if (*key == _T("warning") || *key == _T("WARN")) { 
    109       report |= LOG_WARNING; 
    110     } else if (*key == _T("debug") || *key == _T("DEBUG")) { 
    111       report |= LOG_DEBUG; 
    112     } 
    113   } 
    114   return report; 
    115 } 
    116 bool nscapi::logging::matches(unsigned int report, NSCAPI::nagiosReturn code) { 
    117   return ( 
    118     (code == NSCAPI::critical && ((report&LOG_CRIT)==LOG_CRIT) ) || 
    119     (code == NSCAPI::error && ((report&LOG_ERROR)==LOG_ERROR) ) || 
    120     (code == NSCAPI::warning && ((report&LOG_WARNING)==LOG_WARNING) ) || 
    121     (code == NSCAPI::log && ((report&LOG_MSG)==LOG_MSG) ) || 
    122     (code == NSCAPI::debug && ((report&LOG_DEBUG)==LOG_DEBUG) ) || 
    123     ( (code != NSCAPI::critical) && (code != NSCAPI::error) && (code != NSCAPI::warning) && (code != NSCAPI::log) && (code != NSCAPI::debug) ) 
    124     ); 
    125 } 
    126  
    127 std::wstring nscapi::logging::to_string(unsigned int report) { 
    128   std::wstring ret; 
    129   if ((report&LOG_CRIT)!=0) { 
    130     if (!ret.empty()) ret += _T(","); 
    131     ret += _T("critical"); 
    132   } 
    133   if ((report&LOG_ERROR)!=0) { 
    134     if (!ret.empty()) ret += _T(","); 
    135     ret += _T("error"); 
    136   } 
    137   if ((report&LOG_WARNING)!=0) { 
    138     if (!ret.empty()) ret += _T(","); 
    139     ret += _T("warning"); 
    140   } 
    141   if ((report&LOG_MSG)!=0) { 
    142     if (!ret.empty()) ret += _T(","); 
    143     ret += _T("message"); 
    144   } 
    145   if ((report&LOG_DEBUG)!=0) { 
    146     if (!ret.empty()) ret += _T(","); 
    147     ret += _T("debug"); 
    148   } 
    149   return ret; 
     95    PARSE_LOGLEVEL_BEGIN() 
     96      PARSE_LOGLEVEL("all",   NSCAPI::log_level::trace) 
     97      PARSE_LOGLEVEL("normal",  NSCAPI::log_level::info) 
     98      PARSE_LOGLEVEL("service", NSCAPI::log_level::log) 
     99      PARSE_LOGLEVEL("log",   NSCAPI::log_level::log) 
     100      PARSE_LOGLEVEL("message", NSCAPI::log_level::info) 
     101      PARSE_LOGLEVEL("error",   NSCAPI::log_level::error) 
     102      PARSE_LOGLEVEL("critical",  NSCAPI::log_level::critical) 
     103      PARSE_LOGLEVEL("debug",   NSCAPI::log_level::debug) 
     104      PARSE_LOGLEVEL("trace",   NSCAPI::log_level::trace) 
     105      PARSE_LOGLEVEL("info",    NSCAPI::log_level::info) 
     106      PARSE_LOGLEVEL("warning", NSCAPI::log_level::warning) 
     107    PARSE_LOGLEVEL_END() 
     108  } 
     109  return level; 
     110} 
     111bool nscapi::logging::matches(NSCAPI::log_level::level level, NSCAPI::nagiosReturn code) { 
     112  return code <= level; 
     113} 
     114 
     115#define RENDER_LOGLEVEL_BEGIN()  
     116#define RENDER_LOGLEVEL(key_str, value)  if (level == value) { return _T(key_str); } 
     117#define RENDER_LOGLEVEL_END()  
     118 
     119std::wstring nscapi::logging::to_string(NSCAPI::log_level::level level) { 
     120  RENDER_LOGLEVEL_BEGIN() 
     121    RENDER_LOGLEVEL("all",    NSCAPI::log_level::trace) 
     122    RENDER_LOGLEVEL("normal", NSCAPI::log_level::info) 
     123    RENDER_LOGLEVEL("log",    NSCAPI::log_level::log) 
     124    RENDER_LOGLEVEL("message",  NSCAPI::log_level::info) 
     125    RENDER_LOGLEVEL("error",    NSCAPI::log_level::error) 
     126    RENDER_LOGLEVEL("critical", NSCAPI::log_level::critical) 
     127    RENDER_LOGLEVEL("debug",    NSCAPI::log_level::debug) 
     128    RENDER_LOGLEVEL("trace",    NSCAPI::log_level::trace) 
     129    RENDER_LOGLEVEL("info",   NSCAPI::log_level::info) 
     130    RENDER_LOGLEVEL("warning",  NSCAPI::log_level::warning) 
     131  RENDER_LOGLEVEL_END() 
     132  return strEx::itos(level); 
    150133} 
    151134 
     
    198181std::wstring nscapi::plugin_helper::translateMessageType(NSCAPI::messageTypes msgType) { 
    199182  switch (msgType) { 
    200     case NSCAPI::error: 
     183    case NSCAPI::log_level::error: 
    201184      return _T("error"); 
    202     case NSCAPI::critical: 
     185    case NSCAPI::log_level::critical: 
    203186      return _T("critical"); 
    204     case NSCAPI::warning: 
     187    case NSCAPI::log_level::warning: 
    205188      return _T("warning"); 
    206     case NSCAPI::log: 
     189    case NSCAPI::log_level::log: 
    207190      return _T("message"); 
    208     case NSCAPI::debug: 
     191    case NSCAPI::log_level::debug: 
    209192      return _T("debug"); 
    210193  } 
  • include/nscapi/nscapi_helper.hpp

    rd66ccee r8013c0c  
    4848  } 
    4949  namespace logging { 
    50     unsigned int parse(std::wstring str); 
    51     bool matches(unsigned int report, NSCAPI::nagiosReturn code); 
    52     std::wstring to_string(unsigned int report); 
     50    NSCAPI::log_level::level parse(std::wstring str); 
     51    bool matches(NSCAPI::log_level::level level, NSCAPI::nagiosReturn code); 
     52    std::wstring to_string(NSCAPI::log_level::level level); 
    5353  } 
    5454}; 
  • include/nscapi/nscapi_plugin_wrapper.cpp

    rba63b95 r8013c0c  
    119119    nscapi::functions::create_simple_submit_response(channel, command, ret, _T(""), response); 
    120120  } catch (std::exception &e) { 
    121     nscapi::plugin_singleton->get_core()->log(NSCAPI::error, __FILE__, __LINE__, utf8::cvt<std::wstring>("Failed to parse data from: " + strEx::strip_hex(request) + ": " + e.what())); 
     121    nscapi::plugin_singleton->get_core()->log(NSCAPI::log_level::error, __FILE__, __LINE__, utf8::cvt<std::wstring>("Failed to parse data from: " + strEx::strip_hex(request) + ": " + e.what())); 
    122122  } catch (...) { 
    123     nscapi::plugin_singleton->get_core()->log(NSCAPI::error, __FILE__, __LINE__, utf8::cvt<std::wstring>("Failed to parse data from: " + strEx::strip_hex(request))); 
     123    nscapi::plugin_singleton->get_core()->log(NSCAPI::log_level::error, __FILE__, __LINE__, utf8::cvt<std::wstring>("Failed to parse data from: " + strEx::strip_hex(request))); 
    124124  } 
    125125  return NSCAPI::returnIgnored; 
  • include/nscapi/settings_proxy.hpp

    r40fca56 r8013c0c  
    5252 
    5353    virtual void err(std::string file, int line, std::wstring message) { 
    54       core_->log(NSCAPI::error, file, line, message); 
     54      core_->log(NSCAPI::log_level::error, file, line, message); 
    5555    } 
    5656    virtual void warn(std::string file, int line, std::wstring message) { 
    57       core_->log(NSCAPI::warning, file, line, message); 
     57      core_->log(NSCAPI::log_level::warning, file, line, message); 
    5858    } 
    5959    virtual void info(std::string file, int line, std::wstring message)  { 
    60       core_->log(NSCAPI::log, file, line, message); 
     60      core_->log(NSCAPI::log_level::log, file, line, message); 
    6161    } 
    6262    virtual void debug(std::string file, int line, std::wstring message)  { 
    63       core_->log(NSCAPI::debug, file, line, message); 
     63      core_->log(NSCAPI::log_level::debug, file, line, message); 
    6464    } 
    6565  }; 
  • include/settings/client/settings_client.cpp

    rf7a074d r8013c0c  
    1111    } 
    1212*/ 
    13     wstring_key_type* wstring_key(std::wstring *val, std::wstring def) { 
    14       wstring_key_type* r = new wstring_key_type(val, def); 
     13    boost::shared_ptr<wstring_key_type> wstring_key(std::wstring *val, std::wstring def) { 
     14      boost::shared_ptr<wstring_key_type> r(new wstring_key_type(val, def)); 
    1515      return r; 
    1616    } 
    17     wpath_key_type* wpath_key(std::wstring *val, std::wstring def) { 
    18       wpath_key_type* r = new wpath_key_type(val, def); 
     17    boost::shared_ptr<wpath_key_type> wpath_key(std::wstring *val, std::wstring def) { 
     18      boost::shared_ptr<wpath_key_type> r(new wpath_key_type(val, def)); 
    1919      return r; 
    2020    } 
    21     string_key_type* string_key(std::string *val, std::string def) { 
    22       string_key_type* r = new string_key_type(val, def); 
     21    boost::shared_ptr<string_key_type> string_key(std::string *val, std::string def) { 
     22      boost::shared_ptr<string_key_type> r(new string_key_type(val, def)); 
    2323      return r; 
    2424    } 
    25     int_key_type* int_key(int *val, int def) { 
    26       int_key_type* r = new int_key_type(val, def); 
     25    boost::shared_ptr<int_key_type> int_key(int *val, int def) { 
     26      boost::shared_ptr<int_key_type> r(new int_key_type(val, def)); 
    2727      return r; 
    2828    } 
    29     uint_key_type* uint_key(unsigned int *val, unsigned int def) { 
    30       uint_key_type* r = new uint_key_type(val, def); 
     29    boost::shared_ptr<uint_key_type> uint_key(unsigned int *val, unsigned int def) { 
     30      boost::shared_ptr<uint_key_type> r(new uint_key_type(val, def)); 
    3131      return r; 
    3232    } 
    33     bool_key_type* bool_key(bool *val, bool def) { 
    34       bool_key_type* r = new bool_key_type(val, def); 
     33    boost::shared_ptr<bool_key_type> bool_key(bool *val, bool def) { 
     34      boost::shared_ptr<bool_key_type> r(new bool_key_type(val, def)); 
    3535      return r; 
    3636    } 
    3737 
    3838 
    39     typed_path_fun* fun_path(boost::function<void (std::wstring)> fun) { 
    40       typed_path_fun* r = new typed_path_fun(fun); 
     39    boost::shared_ptr<typed_path_fun> fun_path(boost::function<void (std::wstring)> fun) { 
     40      boost::shared_ptr<typed_path_fun> r(new typed_path_fun(fun)); 
    4141      return r; 
    4242    } 
    43     typed_path_fun_value* fun_values_path(boost::function<void (std::wstring,std::wstring)> fun) { 
    44       typed_path_fun_value* r = new typed_path_fun_value(fun); 
     43    boost::shared_ptr<typed_path_fun_value> fun_values_path(boost::function<void (std::wstring,std::wstring)> fun) { 
     44      boost::shared_ptr<typed_path_fun_value> r(new typed_path_fun_value(fun)); 
    4545      return r; 
    4646    } 
    47     typed_path_map<>* wstring_map_path(std::map<std::wstring,std::wstring> *val) { 
    48       typed_path_map<>* r = new typed_path_map<>(val); 
     47    boost::shared_ptr<typed_path_map<> > wstring_map_path(std::map<std::wstring,std::wstring> *val) { 
     48      boost::shared_ptr<typed_path_map<> > r(new typed_path_map<>(val)); 
    4949      return r; 
    5050    } 
    51     typed_path_list* wstring_list_path(std::list<std::wstring> *val) { 
    52       typed_path_list* r = new typed_path_list(val); 
     51    boost::shared_ptr<typed_path_list> wstring_list_path(std::list<std::wstring> *val) { 
     52      boost::shared_ptr<typed_path_list> r(new typed_path_list(val)); 
    5353      return r; 
    5454    } 
  • include/settings/client/settings_client.hpp

    rf7a074d r8013c0c  
    167167 
    168168    template<typename T> 
    169     typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >* wstring_vector_key(T *val, typename T::key_type key, std::wstring def) { 
    170       typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >* r = new typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >(val, key, def); 
     169    boost::shared_ptr<typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> > > wstring_vector_key(T *val, typename T::key_type key, std::wstring def) { 
     170      boost::shared_ptr<typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> > > r(new typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >(val, key, def)); 
    171171      return r; 
    172172    } 
     
    183183    typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >* wstring_vector_key(T *val, typename T::key_type key, std::wstring def); 
    184184    */ 
    185     wstring_key_type* wstring_key(std::wstring *val, std::wstring def = _T("")); 
    186     string_key_type* string_key(std::string *val, std::string def = ""); 
    187     int_key_type* int_key(int *val, int def = 0); 
    188     uint_key_type* uint_key(unsigned int *val, unsigned int def = 0); 
    189     bool_key_type* bool_key(bool *val, bool def = false); 
    190     wpath_key_type* wpath_key(std::wstring *val, std::wstring def = _T("")); 
    191  
    192     template<class T> 
    193     typed_key_fun<T, typed_int_value<T> >* int_fun_key(boost::function<void (T)> fun, T def) { 
    194       typed_key_fun<T, typed_int_value<T> >* r = new typed_key_fun<T, typed_int_value<T> >(fun, def); 
     185    boost::shared_ptr<wstring_key_type> wstring_key(std::wstring *val, std::wstring def = _T("")); 
     186    boost::shared_ptr<string_key_type> string_key(std::string *val, std::string def = ""); 
     187    boost::shared_ptr<int_key_type> int_key(int *val, int def = 0); 
     188    boost::shared_ptr<uint_key_type> uint_key(unsigned int *val, unsigned int def = 0); 
     189    boost::shared_ptr<bool_key_type> bool_key(bool *val, bool def = false); 
     190    boost::shared_ptr<wpath_key_type> wpath_key(std::wstring *val, std::wstring def = _T("")); 
     191 
     192    template<class T> 
     193    boost::shared_ptr<typed_key_fun<T, typed_int_value<T> > > int_fun_key(boost::function<void (T)> fun, T def) { 
     194      boost::shared_ptr<typed_key_fun<T, typed_int_value<T> > > r(new typed_key_fun<T, typed_int_value<T> >(fun, def)); 
    195195      return r; 
    196196    } 
    197197    template<class T> 
    198     typed_key_fun<T, typed_bool_value<T> >* bool_fun_key(boost::function<void (T)> fun, T def) { 
    199       typed_key_fun<T, typed_bool_value<T> >* r = new typed_key_fun<T, typed_bool_value<T> >(fun, def); 
     198    boost::shared_ptr<typed_key_fun<T, typed_bool_value<T> > > bool_fun_key(boost::function<void (T)> fun, T def) { 
     199      boost::shared_ptr<typed_key_fun<T, typed_bool_value<T> > > r(new typed_key_fun<T, typed_bool_value<T> >(fun, def)); 
    200200      return r; 
    201201    } 
    202202    template<class T> 
    203     typed_key_fun<T, typed_string_value<T> >* string_fun_key(boost::function<void (T)> fun, T def) { 
    204       typed_key_fun<T, typed_string_value<T> >* r = new typed_key_fun<T, typed_string_value<T> >(fun, def); 
     203    boost::shared_ptr<typed_key_fun<T, typed_string_value<T> > > string_fun_key(boost::function<void (T)> fun, T def) { 
     204      boost::shared_ptr<typed_key_fun<T, typed_string_value<T> > > r(new typed_key_fun<T, typed_string_value<T> >(fun, def)); 
    205205      return r; 
    206206    } 
     
    285285 
    286286 
    287     typed_path_fun* fun_path(boost::function<void (std::wstring)> fun); 
    288     typed_path_fun_value* fun_values_path(boost::function<void (std::wstring,std::wstring)> fun); 
    289     typed_path_map<>* wstring_map_path(std::map<std::wstring,std::wstring> *val); 
    290     typed_path_list* wstring_list_path(std::list<std::wstring> *val); 
     287    boost::shared_ptr<typed_path_fun> fun_path(boost::function<void (std::wstring)> fun); 
     288    boost::shared_ptr<typed_path_fun_value> fun_values_path(boost::function<void (std::wstring,std::wstring)> fun); 
     289    boost::shared_ptr<typed_path_map<> > wstring_map_path(std::map<std::wstring,std::wstring> *val); 
     290    boost::shared_ptr<typed_path_list> wstring_list_path(std::list<std::wstring> *val); 
    291291 
    292292    struct description_container { 
     
    328328      description_container description; 
    329329 
    330       key_info(std::wstring path_, std::wstring key_name_, key_interface* key, description_container description_)  
     330      key_info(std::wstring path_, std::wstring key_name_, boost::shared_ptr<key_interface> key, description_container description_)  
    331331        : path(path_) 
    332332        , key_name(key_name_) 
     
    359359 
    360360      path_info(std::wstring path_name, description_container description_) : path_name(path_name), description(description_) {} 
    361       path_info(std::wstring path_name, path_interface* path, description_container description_) : path_name(path_name), path(path), description(description_) {} 
     361      path_info(std::wstring path_name, boost::shared_ptr<path_interface> path, description_container description_) : path_name(path_name), path(path), description(description_) {} 
    362362 
    363363      path_info(const path_info& obj) : path_name(obj.path_name), description(obj.description), path(obj.path) {} 
     
    377377      settings_paths_easy_init(std::wstring path, settings_registry* owner) : path_(path), owner(owner) {} 
    378378 
    379       settings_paths_easy_init& operator()(path_interface *value, std::wstring title, std::wstring description) { 
     379      settings_paths_easy_init& operator()(boost::shared_ptr<path_interface> value, std::wstring title, std::wstring description) { 
    380380        boost::shared_ptr<path_info> d(new path_info(path_, value, description_container(title, description))); 
    381381        add(d); 
     
    394394        return *this; 
    395395      } 
    396       settings_paths_easy_init& operator()(std::wstring path, path_interface *value, std::wstring title, std::wstring description) { 
     396      settings_paths_easy_init& operator()(std::wstring path, boost::shared_ptr<path_interface> value, std::wstring title, std::wstring description) { 
    397397        if (!path_.empty()) 
    398398          path = path_ + _T("/") + path; 
     
    415415      settings_keys_easy_init(std::wstring path, std::wstring parent, settings_registry* owner_) : owner(owner_), path_(path), parent_(parent) {} 
    416416 
    417       settings_keys_easy_init& operator()(std::wstring path, std::wstring key_name, key_interface *value, std::wstring title, std::wstring description) { 
     417      settings_keys_easy_init& operator()(std::wstring path, std::wstring key_name, boost::shared_ptr<key_interface> value, std::wstring title, std::wstring description) { 
    418418        boost::shared_ptr<key_info> d(new key_info(path, key_name, value, description_container(title, description))); 
    419419        if (!parent_.empty()) 
     
    423423      } 
    424424 
    425       settings_keys_easy_init& operator()(std::wstring key_name, key_interface* value, std::wstring title, std::wstring description) { 
     425      settings_keys_easy_init& operator()(std::wstring key_name, boost::shared_ptr<key_interface> value, std::wstring title, std::wstring description) { 
    426426        boost::shared_ptr<key_info> d(new key_info(path_, key_name, value, description_container(title, description))); 
    427427        if (!parent_.empty()) 
  • include/settings/settings_core.hpp

    rfb7e36a r8013c0c  
    3636 
    3737 
    38   class settings_exception { 
    39     std::wstring error_; 
     38  class settings_exception : std::exception { 
     39    std::string error_; 
    4040  public: 
    4141    ////////////////////////////////////////////////////////////////////////// 
     
    4444    /// 
    4545    /// @author mickem 
    46     settings_exception(std::wstring error) : error_(error) {} 
     46    settings_exception(std::wstring error) : error_(utf8::cvt<std::string>(error)) {} 
     47    settings_exception(std::string error) : error_(utf8::cvt<std::string>(error)) {} 
     48    ~settings_exception() throw() {} 
    4749 
    4850    ////////////////////////////////////////////////////////////////////////// 
     
    5153    /// 
    5254    /// @author mickem 
    53     std::wstring getError() const { return error_; } 
    54     std::wstring getMessage() const { return error_; } 
     55    std::wstring getError() const { return wwhat(); } 
     56    std::wstring getMessage() const { return wwhat(); } 
     57    const char* what() const throw() { 
     58      return error_.c_str(); 
     59    } 
     60    const std::wstring wwhat() const throw() { 
     61      return utf8::to_unicode(error_); 
     62    } 
    5563  }; 
    5664  class KeyNotFoundException : public settings_exception { 
  • modules/CheckNSCP/CheckNSCP.cpp

    ra78a985 r8013c0c  
    7676} 
    7777void CheckNSCP::handleMessage(int msgType, const std::string file, int line, std::string message) { 
    78   if (msgType != NSCAPI::error||msgType != NSCAPI::critical) 
     78  if (msgType > NSCAPI::log_level::error) 
    7979    return; 
    8080  std::string err = render(msgType, file, line, message); 
  • modules/CheckSystem/PDHCollector.cpp

    r7ec3dd1 r8013c0c  
    123123      { 
    124124        ReadLock lock(&mutex_, true, 5000); 
    125         if (!lock.IsLocked())  
     125        if (!lock.IsLocked()) { 
    126126          NSC_LOG_ERROR(_T("Failed to get Mutex!")); 
    127         else { 
     127        } else { 
    128128          try { 
    129129            pdh.gatherData(); 
     
    204204*/ 
    205205void PDHCollector::exitThread(void) { 
    206   if (hStopEvent_ == NULL) 
     206  if (hStopEvent_ == NULL) { 
    207207    NSC_LOG_ERROR(_T("Stop event is not created!")); 
    208   else if (!SetEvent(hStopEvent_)) { 
     208  } else if (!SetEvent(hStopEvent_)) { 
    209209      NSC_LOG_ERROR_STD(_T("SetStopEvent failed")); 
    210210  } 
  • modules/DistributedServer/handler_impl.hpp

    r40fca56 r8013c0c  
    3636 
    3737  void log_debug(std::string file, int line, std::wstring msg) { 
    38     GET_CORE()->log(NSCAPI::debug, file, line, msg); 
     38    if (GET_CORE()->should_log(NSCAPI::log_level::debug)) { 
     39      GET_CORE()->log(NSCAPI::log_level::debug, file, line, msg); 
     40    } 
    3941  } 
    4042  void log_error(std::string file, int line, std::wstring msg) { 
    41     GET_CORE()->log(NSCAPI::error, file, line, msg); 
     43    if (GET_CORE()->should_log(NSCAPI::log_level::error)) { 
     44      GET_CORE()->log(NSCAPI::log_level::error, file, line, msg); 
     45    } 
    4246  } 
    4347}; 
  • modules/FileLogger/FileLogger.cpp

    ra78a985 r8013c0c  
    166166  init_ = true; 
    167167  std::string hello = "Starting to log for: " + utf8::cvt<std::string>(GET_CORE()->getApplicationName()) + " - " + utf8::cvt<std::string>(GET_CORE()->getApplicationVersionString()); 
    168   handleMessage(NSCAPI::log, __FILE__, __LINE__, hello); 
    169   handleMessage(NSCAPI::log, __FILE__, __LINE__, "Log path is: " + file_); 
     168  handleMessage(NSCAPI::log_level::log, __FILE__, __LINE__, hello); 
     169  handleMessage(NSCAPI::log_level::log, __FILE__, __LINE__, "Log path is: " + file_); 
    170170  return true; 
    171171} 
  • modules/LUAScript/script_wrapper.hpp

    r40fca56 r8013c0c  
    261261    } 
    262262    static int info (lua_State *L) { 
    263       return log_any(L, NSCAPI::log); 
     263      return log_any(L, NSCAPI::log_level::info); 
    264264    } 
    265265    static int error (lua_State *L) { 
    266       return log_any(L, NSCAPI::error); 
     266      return log_any(L, NSCAPI::log_level::error); 
    267267    } 
    268268    static int log_any(lua_State *L, int mode) { 
  • modules/NRPEServer/handler_impl.hpp

    r40fca56 r8013c0c  
    3939 
    4040  void log_debug(std::string file, int line, std::wstring msg) { 
    41     GET_CORE()->log(NSCAPI::debug, file, line, msg); 
     41    if (GET_CORE()->should_log(NSCAPI::log_level::debug)) { 
     42      GET_CORE()->log(NSCAPI::log_level::debug, file, line, msg); 
     43    } 
    4244  } 
    4345  void log_error(std::string file, int line, std::wstring msg) { 
    44     GET_CORE()->log(NSCAPI::error, file, line, msg); 
     46    if (GET_CORE()->should_log(NSCAPI::log_level::error)) { 
     47      GET_CORE()->log(NSCAPI::log_level::error, file, line, msg); 
     48    } 
    4549  } 
    4650}; 
  • modules/NSCAClient/NSCAClient.cpp

    rba63b95 r8013c0c  
    125125    if (hostname_ == "auto") { 
    126126      hostname_ = boost::asio::ip::host_name(); 
    127  
    128127    } 
    129128 
     
    134133    nscapi::target_handler::optarget t = targets.find_target(_T("default")); 
    135134    if (t) { 
    136       if (!t->has_option("encryption")) 
    137         t->options[_T("encryption")] = encryption; 
    138       if (!t->has_option("timeout")) 
    139         t->options[_T("timeout")] = strEx::itos(timeout); 
    140       if (!t->has_option("payload length")) 
    141         t->options[_T("payload length")] = strEx::itos(payload_length); 
    142       if (!t->has_option("time offset")) 
    143         t->options[_T("time offset")] = utf8::cvt<std::wstring>(delay); 
    144       if (!t->has_option("password")) 
    145         t->options[_T("password")] = password; 
    146       if (!t->address.empty()) 
    147         t->address = _T("nsca://") + nscahost + _T(":") + strEx::itos(nscaport); 
    148       targets.add(*t); 
     135      nscapi::target_handler::target target = *t; 
     136      if (!target.has_option("encryption")) 
     137        target.options[_T("encryption")] = encryption; 
     138      if (!target.has_option("timeout")) 
     139        target.options[_T("timeout")] = strEx::itos(timeout); 
     140      if (!target.has_option("payload length")) 
     141        target.options[_T("payload length")] = strEx::itos(payload_length); 
     142      if (!target.has_option("time offset")) 
     143        target.options[_T("time offset")] = utf8::cvt<std::wstring>(delay); 
     144      if (!target.has_option("password")) 
     145        target.options[_T("password")] = password; 
     146      if (target.address.empty()) 
     147        target.address = _T("nsca://") + nscahost + _T(":") + strEx::itos(nscaport); 
     148      targets.add(target); 
    149149    } else { 
    150150      NSC_LOG_ERROR(_T("Default target not found!")); 
     
    170170      std::wstring name; 
    171171      try { 
    172         nsca::nsca_encrypt::any_encryption *core = nsca::nsca_encrypt::get_encryption_core(i); 
     172        boost::shared_ptr<nsca::nsca_encrypt::any_encryption> core(nsca::nsca_encrypt::get_encryption_core(i)); 
    173173        if (core == NULL) 
    174174          name = _T("Broken<NULL>"); 
     
    292292  if (opt) { 
    293293    nscapi::target_handler::target t = *opt; 
    294     url.host = t.host; 
    295     if (t.has_option("port")) { 
    296       try { 
    297         url.port = strEx::stoi(t.options[_T("port")]); 
    298       } catch (...) {} 
     294    if (t.address.empty()) { 
     295      if (t.host.empty()) 
     296        url.host = t.host; 
     297      if (t.has_option("port")) { 
     298        try { 
     299          url.port = strEx::stoi(t.options[_T("port")]); 
     300        } catch (...) {} 
     301      } 
     302    } else { 
     303      url = net::parse(t.address); 
    299304    } 
    300305    std::string keys[] = {"encryption", "timeout", "payload length", "password", "time offset"}; 
  • modules/NSCAServer/handler_impl.hpp

    r40fca56 r8013c0c  
    5454 
    5555  void log_debug(std::string file, int line, std::wstring msg) { 
    56     GET_CORE()->log(NSCAPI::debug, file, line, msg); 
     56    if (GET_CORE()->should_log(NSCAPI::log_level::debug)) { 
     57      GET_CORE()->log(NSCAPI::log_level::debug, file, line, msg); 
     58    } 
    5759  } 
    5860  void log_error(std::string file, int line, std::wstring msg) { 
    59     GET_CORE()->log(NSCAPI::error, file, line, msg); 
     61    if (GET_CORE()->should_log(NSCAPI::log_level::error)) { 
     62      GET_CORE()->log(NSCAPI::log_level::error, file, line, msg); 
     63    } 
    6064  } 
    6165}; 
  • modules/NSCPServer/handler_impl.hpp

    r40fca56 r8013c0c  
    3636 
    3737  void log_debug(std::string file, int line, std::wstring msg) { 
    38     GET_CORE()->log(NSCAPI::debug, file, line, msg); 
     38    if (GET_CORE()->should_log(NSCAPI::log_level::debug)) { 
     39      GET_CORE()->log(NSCAPI::log_level::debug, file, line, msg); 
     40    } 
    3941  } 
    4042  void log_error(std::string file, int line, std::wstring msg) { 
    41     GET_CORE()->log(NSCAPI::error, file, line, msg); 
     43    if (GET_CORE()->should_log(NSCAPI::log_level::error)) { 
     44      GET_CORE()->log(NSCAPI::log_level::error, file, line, msg); 
     45    } 
    4246  } 
    4347}; 
  • modules/NSClientServer/handler_impl.hpp

    r40fca56 r8013c0c  
    3131 
    3232  void log_debug(std::string file, int line, std::wstring msg) { 
    33     GET_CORE()->log(NSCAPI::debug, file, line, msg); 
     33    if (GET_CORE()->should_log(NSCAPI::log_level::debug)) { 
     34      GET_CORE()->log(NSCAPI::log_level::debug, file, line, msg); 
     35    } 
    3436  } 
    3537  void log_error(std::string file, int line, std::wstring msg) { 
    36     GET_CORE()->log(NSCAPI::error, file, line, msg); 
     38    if (GET_CORE()->should_log(NSCAPI::log_level::error)) { 
     39      GET_CORE()->log(NSCAPI::log_level::error, file, line, msg); 
     40    } 
    3741  } 
    3842 
  • modules/Scheduler/simple_scheduler.cpp

    r9c06054 r8013c0c  
    6767          log_error(_T("NOONE IS HANDLING scheduled item ") + to_wstring((*instance).schedule_id) + _T(" ") + to_wstring(off.total_seconds()) + _T(" seconds to late from thread ") + to_wstring(id)); 
    6868        } 
    69       } else { 
    70         log_error(_T("Nothing is scheduled to run")); 
     69//      } else { 
     70//        log_error(_T("Nothing is scheduled to run")); 
    7171      } 
    7272 
  • scripts/python/lib/test_helper.py

    r441a022 r8013c0c  
    1 from NSCP import Settings, Registry, Core, log, log_error, status 
     1from NSCP import Settings, Registry, Core, log, log_debug, log_error, status 
    22import os 
    33import inspect 
     
    3333  global test_manager 
    3434  if not test_manager: 
    35     log('=== Creating new Test manager ===') 
    3635    test_manager = TestManager(plugin_id, plugin_alias, script_alias) 
    3736     
     
    4342 
    4443    reg.simple_function('py_unittest', run_tests, 'Run python unit test suite') 
    45   else: 
    46     log('=== Reusing existing testmanager ===') 
    4744   
    4845  return test_manager 
     
    8279def setup_singleton(klass, src = None): 
    8380  klass.getInstance = SingletonHelper(klass) 
    84   log('Setting path: %s'%src) 
    8581  if not src: 
    8682    cf = inspect.currentframe() 
     
    9086        src = bf.f_code.co_filename 
    9187  klass.__source__ = src 
    92   log('==>%s'%src) 
    9388 
    9489class BasicTest(object): 
     
    118113    conf = Settings.get() 
    119114    conf.set_string('/modules', 'pytest', 'PythonScript') 
    120     log('==> %s'%self.__source__) 
    121115    fn = os.path.basename(self.__source__) 
    122116    (sn, ext) = os.path.splitext(fn) 
     
    152146  def log(self, prefix = '', indent = 0): 
    153147    if self.status: 
    154       log('%s%s%s'%(prefix, ''.rjust(indent, ' '), self)) 
     148      log_debug('%s%s%s'%(prefix, ''.rjust(indent, ' '), self)) 
    155149    else: 
    156150      log_error('%s%s%s'%(prefix, ''.rjust(indent, ' '), self)) 
     
    189183    start = '%s%s'%(prefix, ''.rjust(indent, ' ')) 
    190184    if self.status: 
    191       log('%s%s'%(start, self)) 
     185      log_debug('%s%s'%(start, self)) 
    192186    else: 
    193187      log_error('%s%s'%(start, self)) 
     
    199193 
    200194  def count(self): 
    201     total_count = 1 
     195    total_count = 0 
    202196    ok_count = 0 
    203     if self.status: 
    204       ok_count = 1 
     197    #if self.status: 
     198    # ok_count = 1 
    205199 
    206200    for c in self.children: 
     
    278272  def return_nagios(self): 
    279273    (total, ok) = self.count() 
    280     log(' | Test result log (only summary will be returned to query)') 
     274    log_debug(' | Test result log (only summary will be returned to query)') 
    281275    self.log(' | ') 
    282276    if total == ok: 
  • service/CMakeLists.txt

    r7515d00 r8013c0c  
    102102# SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS") 
    103103#ENDIF(WIN32) 
    104 #INSTALL(TARGETS ${TARGET} RUNTIME DESTINATION .) 
    105  
    106 #INSTALL(CODE "SET(PDB_FULL_PATH ${BUILD_TARGET_EXE_PATH}/${TARGET}.pdb)") 
    107 #INSTALL(CODE "FILE(INSTALL DESTINATION \${CMAKE_INSTALL_PREFIX} TYPE EXECUTABLE FILES \${PDB_FULL_PATH})") 
     104INSTALL(TARGETS ${TARGET} RUNTIME DESTINATION .) 
     105INSTALL(CODE "SET(PDB_FULL_PATH ${BUILD_TARGET_EXE_PATH}/${TARGET}.pdb)") 
     106INSTALL(CODE "FILE(INSTALL DESTINATION \${CMAKE_INSTALL_PREFIX} TYPE EXECUTABLE FILES \${PDB_FULL_PATH})") 
    108107 
    109108SOURCE_GROUP("NSCP API" REGULAR_EXPRESSION .*include/nscapi/.*) 
  • service/NSClient++.cpp

    r441a022 r8013c0c  
    7373} 
    7474 
    75 #define LOG_CRITICAL_CORE(msg) { std::string s = nsclient::logger_helper::create_error(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
     75#define LOG_CRITICAL_CORE(msg) if (mainClient.should_log(NSCAPI::log_level::critical)) { std::string s = nsclient::logger_helper::create_error(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
    7676#define LOG_CRITICAL_CORE_STD(msg) LOG_CRITICAL_CORE(std::wstring(msg)) 
    77 #define LOG_ERROR_CORE(msg) { std::string s = nsclient::logger_helper::create_error(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
     77#define LOG_ERROR_CORE(msg) if (mainClient.should_log(NSCAPI::log_level::error)) { std::string s = nsclient::logger_helper::create_error(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
    7878#define LOG_ERROR_CORE_STD(msg) LOG_ERROR_CORE(std::wstring(msg)) 
    79 #define LOG_INFO_CORE(msg) { std::string s = nsclient::logger_helper::create_info(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
     79#define LOG_INFO_CORE(msg) if (mainClient.should_log(NSCAPI::log_level::info)) { std::string s = nsclient::logger_helper::create_info(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
    8080#define LOG_INFO_CORE_STD(msg) LOG_INFO_CORE(std::wstring(msg)) 
    81 #define LOG_DEBUG_CORE(msg) { if (mainClient.logDebug()) { std::string s = nsclient::logger_helper::create_debug(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } } 
     81#define LOG_DEBUG_CORE(msg) if (mainClient.should_log(NSCAPI::log_level::debug)) { std::string s = nsclient::logger_helper::create_debug(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
    8282#define LOG_DEBUG_CORE_STD(msg) LOG_DEBUG_CORE(std::wstring(msg)) 
     83#define LOG_TRACE_CORE(msg) if (mainClient.should_log(NSCAPI::log_level::trace)) { std::string s = nsclient::logger_helper::create_debug(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
     84#define LOG_TRACE_CORE_STD(msg) LOG_DEBUG_CORE(std::wstring(msg)) 
    8385 
    8486/** 
     
    11111113NSCAPI::nagiosReturn NSClientT::injectRAW(const wchar_t* raw_command, std::string &request, std::string &response) { 
    11121114  std::wstring cmd = nsclient::commands::make_key(raw_command); 
    1113   if (logDebug()) { 
    1114     LOG_DEBUG_CORE_STD(_T("Injecting: ") + cmd + _T("...")); 
    1115   } 
     1115  LOG_DEBUG_CORE_STD(_T("Injecting: ") + cmd + _T("...")); 
    11161116  /*if (shared_client_.get() != NULL && shared_client_->hasMaster()) { 
    11171117    try { 
     
    14311431} 
    14321432 
    1433 bool NSClientT::logDebug() { 
    1434   if (debug_ == log_state_unknown) { 
    1435     debug_ = log_state_looking; 
     1433NSCAPI::log_level::level NSClientT::get_loglevel() { 
     1434  if (log_status_ == log_state_unknown) { 
     1435    log_status_ = log_state_looking; 
    14361436    try { 
    1437       if (settings_manager::get_settings_no_wait()->get_bool(_T("log"), _T("debug"), false) == 1) 
    1438         debug_ = log_state_debug; 
    1439       else 
    1440         debug_ = log_state_nodebug; 
     1437      if (settings_manager::get_settings_no_wait()->get_bool(_T("log"), _T("debug"), false) == 1) { 
     1438        log_level_ = nscapi::logging::parse(_T("debug")); 
     1439        log_status_ = log_state_set; 
     1440      } else { 
     1441        std::wstring level = settings_manager::get_settings_no_wait()->get_string(_T("log"), _T("level"), _T("service")); 
     1442        log_level_ = nscapi::logging::parse(level); 
     1443        log_status_ = log_state_set; 
     1444      } 
    14411445    } catch (settings::settings_exception e) { 
    1442       debug_ = log_state_unknown; 
    1443       return false; 
    1444     } 
    1445   } else if (debug_ == log_state_looking)  
    1446     return false; 
    1447   return (debug_ == log_state_debug); 
     1446      log_status_ = log_state_unknown; 
     1447    } 
     1448  } 
     1449  return log_level_; 
     1450} 
     1451 
     1452bool NSClientT::should_log(NSCAPI::nagiosReturn level) { 
     1453  return nscapi::logging::matches(get_loglevel(), level); 
     1454} 
     1455void NSClientT::set_loglevel(std::wstring level) { 
     1456  log_status_ = log_state_set; 
     1457  NSCAPI::log_level::level new_log_level = nscapi::logging::parse(level); 
     1458  if (new_log_level != log_level_) { 
     1459    //update_log_level() TODO 
     1460    log_level_ = new_log_level; 
     1461  } 
    14481462} 
    14491463 
  • service/NSClient++.h

    r89838be r8013c0c  
    2424#include <com_helpers.hpp> 
    2525#endif 
     26 
    2627 
    2728#include <types.hpp> 
     
    9798  //boost::shared_mutex m_mutexRWcmdDescriptions; 
    9899  //cmdMap cmdDescriptions_; 
    99   enum log_status {log_state_unknown, log_state_looking, log_state_debug, log_state_nodebug }; 
    100   log_status debug_; 
     100  enum log_status {log_state_unknown, log_state_looking, log_state_set }; 
     101  log_status log_status_; 
     102  NSCAPI::log_level::level log_level_; 
    101103  std::wstring context_; 
    102104#ifdef WIN32 
     
    119121  typedef std::multimap<std::wstring,std::wstring> plugin_alias_list_type; 
    120122  // c-tor, d-tor 
    121   NSClientT(void) : debug_(log_state_unknown), enable_shared_session_(false), commands_(this), channels_(this), routers_(this), next_plugin_id_(0), service_name_(DEFAULT_SERVICE_NAME) { 
     123  NSClientT(void) : log_status_(log_state_unknown), log_level_(NSCAPI::log_level::log), enable_shared_session_(false), commands_(this), channels_(this), routers_(this), next_plugin_id_(0), service_name_(DEFAULT_SERVICE_NAME) { 
    122124    logger_master_.start_slave(); 
    123125  } 
    124126  virtual ~NSClientT(void) {} 
    125   void enableDebug(bool debug = true) { 
    126     if (debug) 
    127       debug_ = log_state_debug; 
    128     else 
    129       debug_ = log_state_nodebug; 
    130   } 
     127  NSCAPI::log_level::level get_loglevel(); 
     128  void set_loglevel(std::wstring level); 
    131129 
    132130  // Service helper functions 
     
    213211  void startTrayIcon(DWORD dwSessionId); 
    214212 
    215   bool logDebug(); 
     213  bool should_log(NSCAPI::nagiosReturn level); 
    216214  void listPlugins(); 
    217215  plugin_info_list get_all_plugins(); 
  • service/cli_parser.hpp

    r441a022 r8013c0c  
    1515  po::options_description common; 
    1616 
    17   bool debug; 
    1817  bool help; 
    1918  bool version; 
     19  std::wstring log_level; 
     20  std::wstring settings_store; 
    2021 
    2122public: 
     
    2728    , service("Service Options") 
    2829    , client("Client Options") 
    29     , debug(false) 
    3030    , help(false) 
    3131    , version(false) 
     
    3737      ("client-help", "Produce help message for the various settings related client") 
    3838      ("test-help", "Produce help message for the various settings related client") 
    39  
     39/* 
    4040      ("settings", "Enter settings mode and handle settings related commands") 
    4141      ("service", "Enter service mode and handle service related commands") 
    4242      ("client", "Enter client mode and handle client related commands") 
    4343      ("test", "Start test and debug mode") 
     44      */ 
    4445      ("version", po::bool_switch(&version), "Show version information") 
    4546      ; 
    4647    common.add_options() 
     48      ("settings", po::value<std::wstring>(&settings_store), "Override (temporarily) settings subsystem to use") 
    4749      ("help", po::bool_switch(&help), "produce help message") 
    48       ("debug", po::bool_switch(&debug), "Show debug information") 
     50      ("debug", "Set log level to debug (and show debug information)") 
     51      ("log", po::value<std::wstring>(&log_level), "The log level to use") 
    4952      ("version", po::bool_switch(&version), "Show version information") 
    5053      ; 
    5154 
    5255    settings.add_options() 
    53       ("settings", po::value<std::wstring>(), "Override (temporarily) settings subsystem to use") 
    5456      ("migrate-to", po::value<std::wstring>(), "Migrate (copy) settings from current store to target store") 
    5557      ("migrate-from", po::value<std::wstring>(), "Migrate (copy) settings from current store to target store") 
     
    8082      ("query,q", po::value<std::wstring>(), "Run a query with a given name") 
    8183      ("submit,s", po::value<std::wstring>(), "Name of query to ask") 
    82       ("settings", po::value<std::wstring>(), "Override (temporarily) settings subsystem to use") 
    8384      ("module,M", po::value<std::wstring>(), "Name of module to load (if not specified all modules in ini file will be loaded)") 
    8485      ("argument,a", po::wvalue<std::vector<std::wstring> >(), "List of arguments (gets -- prefixed automatically)") 
     
    9091  bool process_common_options(std::string context, po::options_description &desc) { 
    9192    core_->set_console_log(); 
    92     if (debug) { 
    93       core_->enableDebug(true); 
    94       core_->log_debug(__FILE__, __LINE__, _T("Enabling debug mode")); 
    95     } 
     93    if (!log_level.empty()) 
     94      core_->set_loglevel(log_level); 
     95    if (!settings_store.empty()) 
     96      core_->set_settings_context(settings_store); 
    9697 
    9798    if (help) { 
     
    184185 
    185186    core_->set_console_log(); 
    186     core_->enableDebug(true); 
    187  
    188 //    if (argc > 2 && wcscasecmp( _T("server"), argv[2] ) == 0 ) { 
    189 //      server = true; 
    190 //    } 
    191 //    std::wcout << "Launching test mode - " << (server?_T("server mode"):_T("client mode")) << std::endl; 
    192 //    LOG_MESSAGE_STD(_T("Booting: ") SZSERVICEDISPLAYNAME ); 
    193     nsclient::simple_client client(core_); 
    194     client.start(); 
    195     return 0; 
     187    core_->set_loglevel(_T("debug")); 
     188 
     189 
     190    try { 
     191      po::options_description all("Allowed options (settings)"); 
     192      all.add(common).add(settings); 
     193 
     194      po::variables_map vm; 
     195      po::store(po::parse_command_line(argc, argv, all), vm); 
     196      po::notify(vm); 
     197 
     198      if (process_common_options("settings", all)) 
     199        return 1; 
     200 
     201      nsclient::simple_client client(core_); 
     202      client.start(); 
     203      return 0; 
     204    } catch(std::exception & e) { 
     205      mainClient.log_error(__FILE__, __LINE__, std::string("Unable to parse command line (settings): ") + e.what()); 
     206      return 1; 
     207    } 
    196208  } 
    197209 
     
    287299        mainClient.log_info(__FILE__, __LINE__, _T("TODO retrieve name from service here")); 
    288300      } 
    289       if (debug) { 
     301      if (mainClient.should_log(NSCAPI::log_level::debug)) { 
    290302        mainClient.log_info(__FILE__, __LINE__, _T("Service name: ") + name); 
    291303        mainClient.log_info(__FILE__, __LINE__, _T("Service description: ") + desc); 
     
    294306      if (vm.count("run")) { 
    295307        try { 
    296           mainClient.enableDebug(true); 
    297308          mainClient.start_and_wait(name); 
    298309        } catch (...) { 
     
    395406      } 
    396407 
    397       if (debug) { 
     408      if (mainClient.should_log(NSCAPI::log_level::debug)) { 
    398409        mainClient.log_info(__FILE__, __LINE__, _T("Module: ") + module); 
    399410        mainClient.log_info(__FILE__, __LINE__, _T("Command: ") + command); 
     
    407418        mainClient.log_info(__FILE__, __LINE__, _T("Arguments: ") + args); 
    408419      } 
    409       if (vm.count("settings")) 
    410         core_->set_settings_context(vm["settings"].as<std::wstring>()); 
    411420 
    412421      core_->boot_init(); 
     
    453462      } 
    454463      return ret; 
    455     } catch(std::exception & e) { 
     464    } catch(const std::exception & e) { 
    456465      std::wcerr << _T("Client: Unable to parse command line: ") << utf8::to_unicode(e.what()) << std::endl; 
    457466      return 1; 
  • service/core_api.cpp

    r40fca56 r8013c0c  
    169169 
    170170NSCAPI::boolReturn NSAPICheckLogMessages(int messageType) { 
    171   if (mainClient.logDebug()) 
    172     return NSCAPI::istrue; 
    173   return NSCAPI::isfalse; 
     171  return mainClient.should_log(messageType); 
    174172} 
    175173 
     
    513511  if (wcscasecmp(buffer, _T("NSAPIReload")) == 0) 
    514512    return reinterpret_cast<LPVOID>(&NSAPIReload); 
     513  if (wcscasecmp(buffer, _T("NSAPIGetLoglevel")) == 0) 
     514    return reinterpret_cast<LPVOID>(&NSAPIGetLoglevel); 
    515515 
    516516  LOG_ERROR_STD(_T("Function not found: ") + buffer); 
     
    541541  delete [] *buffer; 
    542542} 
     543 
     544NSCAPI::log_level::level NSAPIGetLoglevel() { 
     545  return mainClient.get_loglevel(); 
     546} 
  • service/core_api.h

    rf7a074d r8013c0c  
    6767NSCAPI::errorReturn NSAPIRegisterRoutingListener(unsigned int plugin_id, const wchar_t* channel); 
    6868NSCAPI::errorReturn NSAPIReload(const wchar_t*); 
     69NSCAPI::log_level::level NSAPIGetLoglevel(); 
  • service/logger.hpp

    r330af36 r8013c0c  
    151151        int code = nscapi::functions::gpb_to_log(l); 
    152152        switch (code) { 
    153           case NSCAPI::critical: 
     153          case NSCAPI::log_level::critical: 
    154154            return _T("c"); 
    155           case NSCAPI::warning: 
     155          case NSCAPI::log_level::warning: 
    156156            return _T("w"); 
    157           case NSCAPI::error: 
     157          case NSCAPI::log_level::error: 
    158158            return _T("e"); 
    159           case NSCAPI::log: 
     159          case NSCAPI::log_level::log: 
    160160            return _T("l"); 
    161           case NSCAPI::debug: 
     161          case NSCAPI::log_level::debug: 
    162162            return _T("d"); 
    163163          default: 
  • service/settings_logger_impl.cpp

    r58f0e80 r8013c0c  
    1111/// @author mickem 
    1212void settings_logger::err(std::string file, int line, std::wstring message) { 
     13  if (!mainClient.should_log(NSCAPI::log_level::error)) 
     14    return; 
    1315  std::string s = nsclient::logger_helper::create_error(file.c_str(), line, message.c_str()); 
    1416  mainClient.reportMessage(s); 
     
    2325/// @author mickem 
    2426void settings_logger::warn(std::string file, int line, std::wstring message) { 
     27  if (!mainClient.should_log(NSCAPI::log_level::warning)) 
     28    return; 
    2529  std::string s = nsclient::logger_helper::create_warning(file.c_str(), line, message.c_str()); 
    2630  mainClient.reportMessage(s); 
     
    3539/// @author mickem 
    3640void settings_logger::info(std::string file, int line, std::wstring message) { 
     41  if (!mainClient.should_log(NSCAPI::log_level::info)) 
     42    return; 
    3743  std::string s = nsclient::logger_helper::create_info(file.c_str(), line, message.c_str()); 
    3844  mainClient.reportMessage(s); 
     
    4753/// @author mickem 
    4854void settings_logger::debug(std::string file, int line, std::wstring message) { 
    49   if (!mainClient.logDebug()) 
     55  if (!mainClient.should_log(NSCAPI::log_level::debug)) 
    5056    return; 
    5157  std::string s = nsclient::logger_helper::create_debug(file.c_str(), line, message.c_str()); 
  • service/simple_client.hpp

    r89838be r8013c0c  
    1414    } 
    1515    void start() { 
    16       core_->enableDebug(true); 
    1716      if (!core_->boot_init()) { 
    1817        core_->log_error(__FILE__, __LINE__, _T("Service failed to init")); 
     
    5857          for (std::list<std::wstring>::const_iterator cit = lst.begin(); cit!=lst.end();++cit) 
    5958            log(_T("| ") + *cit + _T(": ") + core_->describeCommand(*cit)); 
    60         } else if (s == _T("debug off")) { 
    61           log(_T("Setting debug log off...")); 
    62           core_->enableDebug(false); 
    63         } else if (s == _T("debug on")) { 
    64           log(_T("Setting debug log on...")); 
    65           core_->enableDebug(true); 
     59        } else if (s.size() > 4 && s.substr(0,3) == _T("log")) { 
     60          log(_T("Setting log to: ") + s.substr(4)); 
     61          core_->set_loglevel(s.substr(4)); 
    6662        } else if (s == _T("reattach")) { 
    6763          log(_T("Reattaching to session 0")); 
  • version.hpp

    rf19371a r8013c0c  
    11#ifndef VERSION_HPP 
    22#define VERSION_HPP 
    3 #define PRODUCTVER     0,4,0,126 
    4 #define STRPRODUCTVER  "0,4,0,126" 
    5 #define STRPRODUCTDATE "2012-01-20" 
     3#define PRODUCTVER     0,4,0,129 
     4#define STRPRODUCTVER  "0,4,0,129" 
     5#define STRPRODUCTDATE "2012-01-21" 
    66#endif // VERSION_HPP 
  • version.txt

    rf19371a r8013c0c  
    11version=0.4.0 
    2 build=126 
    3 date=2012-01-20 
     2build=129 
     3date=2012-01-21 
Note: See TracChangeset for help on using the changeset viewer.