Changed version string to 0.0.8
[gnucomo.git] / src / gcm_input / gcm_input.cpp
index 34d768b..e57b6f2 100644 (file)
@@ -7,7 +7,7 @@
 ***********************
 **      FILE NAME      : gcm_input.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.6 $
+**      VERSION NUMBER : $Revision: 1.10 $
 **
 **  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.6  2003-08-11 16:56:16  arjen
+   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
+   A date without the time for the '-d <date> option will
+   assume midnight on that date.
+
+   Revision 1.8  2003/08/16 15:30:19  arjen
+   Fixed a gcc 2 vs. gcc 3 problem
+
+   Revision 1.7  2003/08/14 10:28:37  arjen
+   Use parameters from a new section 'logging' with three configuration parameters:
+      method       - Output method to use for logging.
+      destination  - Name of the log output destination.
+      level        - Log level: Verbose output if greater than 0.
+
+   Revision 1.6  2003/08/11 16:56:16  arjen
    Different kinds of log files are parsed by a collection of objects
    of different classes, derived from the base class line_cooker
    Depending on the message content or the message_type element in
 
 *****************************/
 
-static const char *RCSID = "$Id: gcm_input.cpp,v 1.6 2003-08-11 16:56:16 arjen Exp $";
+static const char *RCSID = "$Id: gcm_input.cpp,v 1.10 2003-09-03 06:58:31 arjen Exp $";
 
 #include <fstream>
 
@@ -101,7 +117,7 @@ bool testmode = false;
 bool incremental = false;
 std::ostream *log = &std::cerr;
 
-static char *Version = "gcm_input version 0.0.7 - Jul 24, 2003";
+static char *Version = "gcm_input version 0.0.8 - Sep 04, 2003";
 
 
 /*=========================================================================
@@ -154,11 +170,16 @@ int main(int argc, char *argv[])
 
       case 'd':
          arrival = String(optarg);
-         if (!arrival.proper())
+         if (!date(arrival).proper())
          {
-            std::cerr << "gcm_input: Invalid date string: " << optarg << ".\n";
+            std::cerr << "gcm_input: Invalid date string: " << optarg
+                      << "(" << arrival << ").\n";
             exit(1);
          }
+         else if (!hour(arrival).proper())
+         {
+            arrival = UTC(date(arrival), hour(0,0,0));
+         }
          break;
 
       case 's':
@@ -195,27 +216,29 @@ int main(int argc, char *argv[])
       exit(1);
    }
 
-   String logfile_name = cfg.find_parameter("gcm_input", "logfile");
-   int    verbosity    = cfg.find_parameter("gcm_input", "verbosity");
+   String log_method      = cfg.find_parameter("logging", "method");
+   String log_destination = cfg.find_parameter("logging", "destination");
+   int    level           = cfg.find_parameter("gcm_input", "level");
 
-   if (logfile_name != "")
+   if (log_method == "file" && log_destination != "")
    {
-      std::cerr << "Logging to " << logfile_name << ".\n";
-      logfile.open(logfile_name, _IO_APPEND); // for gcc 2
-      //logfile.open(logfile_name, std::ios_base::app); // for gcc 3
+      std::cerr << "Logging to " << log_destination << ".\n";
+#if __GNUC__ == 2
+      logfile.open(log_destination, _IO_APPEND); // for gcc 2
+#else
+      logfile.open(log_destination, std::ios_base::app); // for gcc 3
+#endif
       if (!logfile)
       {
-         std::cerr << "Can't open logfile " << logfile_name << " for writing.\n";
+         std::cerr << "Can't open logfile " << log_destination << " for writing.\n";
       }
       else
       {
          log = &logfile;
-         verbose = verbose || verbosity > 0;
+         verbose = verbose || level > 0;
       }
    }
 
-   *log << "Gcm_input starting at " << Now() << ".\n";
-
    if (verbose)
    {
       *log << "Hostname = " << hostname;
@@ -246,7 +269,6 @@ int main(int argc, char *argv[])
       {
          msg.enter();
       }
-      *log << "Gcm_input finished at " << Now() << ".\n";
       return 0;
    }
    else