Catch exceptions from the database library
authorarjen <arjen>
Mon, 27 Oct 2003 13:00:15 +0000 (13:00 +0000)
committerarjen <arjen>
Mon, 27 Oct 2003 13:00:15 +0000 (13:00 +0000)
src/gcm_input/gcm_input.cpp

index e57b6f2..4215aa4 100644 (file)
@@ -7,7 +7,7 @@
 ***********************
 **      FILE NAME      : gcm_input.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.10 $
+**      VERSION NUMBER : $Revision: 1.11 $
 **
 **  DESCRIPTION      :  Application to store client messages into the database
 **                      The client message contains a log file from one of the
 
 /*****************************
    $Log: gcm_input.cpp,v $
-   Revision 1.10  2003-09-03 06:58:31  arjen
+   Revision 1.11  2003-10-27 13:00:15  arjen
+   Catch exceptions from the database library
+
+   Revision 1.10  2003/09/03 06:58:31  arjen
    Changed version string to 0.0.8
 
    Revision 1.9  2003/09/01 06:59:26  arjen
 
 *****************************/
 
-static const char *RCSID = "$Id: gcm_input.cpp,v 1.10 2003-09-03 06:58:31 arjen Exp $";
+static const char *RCSID = "$Id: gcm_input.cpp,v 1.11 2003-10-27 13:00:15 arjen Exp $";
 
 #include <fstream>
 
@@ -218,11 +221,10 @@ int main(int argc, char *argv[])
 
    String log_method      = cfg.find_parameter("logging", "method");
    String log_destination = cfg.find_parameter("logging", "destination");
-   int    level           = cfg.find_parameter("gcm_input", "level");
+   int    level           = cfg.find_parameter("logging", "level");
 
    if (log_method == "file" && log_destination != "")
    {
-      std::cerr << "Logging to " << log_destination << ".\n";
 #if __GNUC__ == 2
       logfile.open(log_destination, _IO_APPEND); // for gcc 2
 #else
@@ -235,9 +237,9 @@ int main(int argc, char *argv[])
       else
       {
          log = &logfile;
-         verbose = verbose || level > 0;
       }
    }
+   verbose = verbose || level > 0;
 
    if (verbose)
    {
@@ -267,7 +269,14 @@ int main(int argc, char *argv[])
 
       if (msg.classify(hostname, arrival, service) > 0.9)
       {
-         msg.enter();
+         try
+         {
+            msg.enter();
+         }
+         catch (exception &e)
+         {
+            *log << "Caught an exception: " << e.what() << "\n";
+         }
       }
       return 0;
    }