Changeset 633

Show
Ignore:
Timestamp:
03/13/07 23:57:18 (18 months ago)
Author:
hyriand
Message:

Made debugging domains configurable. By default museekd will be completely silent after loading the configuration.--This line, and those below, will be ignored--

M main.cpp

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/newnet/museekd/museekd/main.cpp

    r630 r633  
    4949}; 
    5050 
     51class KeySetCallback : public NewNet::Event<const Museek::ConfigManager::ChangeNotify *>::Callback 
     52{ 
     53public: 
     54  virtual void operator()(const Museek::ConfigManager::ChangeNotify * notice) 
     55  { 
     56    if(notice->domain == "museekd.debug") 
     57    { 
     58      if(museekd->config()->getBool(notice->domain, notice->key)) 
     59        NNLOG.enable(notice->key); 
     60      else 
     61        NNLOG.disable(notice->key); 
     62    } 
     63  } 
     64}; 
     65 
     66class KeyRemovedCallback : public NewNet::Event<const Museek::ConfigManager::RemoveNotify *>::Callback 
     67{ 
     68public: 
     69  virtual void operator()(const Museek::ConfigManager::RemoveNotify * notice) 
     70  { 
     71    if(notice->domain == "museekd.debug") 
     72      NNLOG.disable(notice->key); 
     73  } 
     74}; 
     75 
    5176int main(int argc, char ** argv) 
    5277{ 
    5378  /* Enable various interesting logging domains. */ 
    54   NNLOG.enable("museek.warn"); 
    55   NNLOG.enable("museek.note"); 
    56   NNLOG.enable("museek.debug"); 
    57 //   NNLOG.enable("museek.direntry"); 
    58   NNLOG.enable("museek.messages.iface"); 
    59   NNLOG.enable("museek.messages.server"); 
    60   NNLOG.enable("museek.messages.handshake"); 
    61   NNLOG.enable("museek.messages.peer"); 
     79  NNLOG.enable("ALL"); 
    6280 
    6381  /* Create our Museek Daemon instance. */ 
    6482  museekd = new Museek::Museekd(); 
     83 
     84  /* Connect our config watchers. */ 
     85  museekd->config()->keySetEvent.connect(new KeySetCallback); 
     86  museekd->config()->keyRemovedEvent.connect(new KeyRemovedCallback); 
    6587 
    6688  /* Load the configuration from ~/.museekd/newnet.xml. */ 
     
    7193    return -1; 
    7294  } 
    73    
     95 
     96  /* Disable the debug override. */ 
     97  NNLOG.disable("ALL"); 
     98 
    7499  museekd->LoadShares(); // works, yay ;) 
    75100