[Gnupos-cvs] gnp-server/src GNPS_io.c,1.1.1.1,1.2 Makefile.am,1.2,1.3 main.c,1.2,1.3
Status: Pre-Alpha
Brought to you by:
conrad_c
From: <con...@us...> - 2003-02-20 12:31:32
|
Update of /cvsroot/gnupos/gnp-server/src In directory sc8-pr-cvs1:/tmp/cvs-serv13282/src Modified Files: GNPS_io.c Makefile.am main.c Log Message: Now initialises logging file, and basic logging infrastructure exists. Index: GNPS_io.c =================================================================== RCS file: /cvsroot/gnupos/gnp-server/src/GNPS_io.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** GNPS_io.c 27 Jan 2003 12:22:28 -0000 1.1.1.1 --- GNPS_io.c 20 Feb 2003 12:31:27 -0000 1.2 *************** *** 21,27 **** --- 21,99 ---- /* Copyright (c) 2003 Conrad Canterford. */ + #include <stdio.h> + #include <glib.h> + #include <time.h> + + #include "include/GNPS.h" + + extern gnps_global_data_struct gnps_global_data; + extern int gnps_debug; + extern int gnps_verbose; + + FILE *gnps_log_fh; + void gnps_read_config () { + if(gnps_debug) + printf("Entering gnps_read_config()\n"); + + if(gnps_debug) + printf("Leaving gnps_read_config()\n"); + } + + void + gnps_init_logging () + { + gboolean default_name; + + if(gnps_debug) + printf("Entering gnps_init_logging()\n"); + + if(gnps_global_data.log_file_name == NULL) + { + default_name = TRUE; + gnps_global_data.log_file_name = "/var/log/gnupos"; + } + + gnps_log_fh = fopen(gnps_global_data.log_file_name,"a"); + + if (gnps_log_fh == NULL) + { + printf("ERROR: Could not open log file. ABORTING.\n"); + exit(-1); + } + + logprintf("GnuPOS Server starting. Version: %s",gnps_global_data.version_str); + + if(gnps_debug) + printf("Leaving gnps_init_logging()\n"); + } + + void + logprintf(char *template, ...) + { + time_t tt_p; + struct tm *tm_p; + va_list vp; + + if(gnps_debug) + printf("Entering gnps_logprintf()\n"); + + /* get the time */ + tt_p = time(tt_p); + tm_p = gmtime(&tt_p); + + fprintf(gnps_log_fh,"%02d/%02d/%4d %02d:%02d:%02d UTC - ", + tm_p->tm_mday, tm_p->tm_mon+1, tm_p->tm_year+1900, tm_p->tm_hour, + tm_p->tm_min, tm_p->tm_sec); + + va_start(vp, template); + vfprintf(gnps_log_fh, template, vp); + va_end(vp); + fprintf(gnps_log_fh,"\n"); + + if(gnps_debug) + printf("Leaving logprintf()\n"); } Index: Makefile.am =================================================================== RCS file: /cvsroot/gnupos/gnp-server/src/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 9 Feb 2003 12:36:50 -0000 1.2 --- Makefile.am 20 Feb 2003 12:31:27 -0000 1.3 *************** *** 5,9 **** ## Please disable it in the Anjuta project configuration ! INCLUDES = ../include CFLAGS =\ --- 5,11 ---- ## Please disable it in the Anjuta project configuration ! INCLUDES = ../include \ ! -I/usr/include/glib-1.2 \ ! -I/usr/lib/glib/include CFLAGS =\ Index: main.c =================================================================== RCS file: /cvsroot/gnupos/gnp-server/src/main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.c 9 Feb 2003 12:36:50 -0000 1.2 --- main.c 20 Feb 2003 12:31:27 -0000 1.3 *************** *** 80,83 **** --- 80,84 ---- printf("GnuPOS Server\nVersion: %s\n\n\n",VERSION); + gnps_global_data.version_str = VERSION; pc=poptGetContext("GnuPOS Server", argc, argv, options, POPT_CONTEXT_NO_EXEC); *************** *** 103,106 **** --- 104,112 ---- gnps_global_data.verbose_logging = TRUE; } + + if(gnps_verbose) + printf("Starting Logging NOW.\n"); + + gnps_init_logging(); if(gnps_verbose) |