Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

logger.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                                    logger.h
00003                              -------------------
00004     begin                : Sat Nov 3 2001
00005     copyright            : (C) 2001-2002 by Christian Hoenig & Gunter Ohrner
00006     email                : pdepp@CustomCDROM.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00023 #ifndef LOGGER_H_FLAG
00024 #define LOGGER_H_FLAG
00025 
00026 #include "common.h"
00027 
00028 
00029 // If we have stdarg.h, include it. (GNU)
00030 #ifdef HAVE_STDARG_H
00031 # include <stdarg.h>
00032 #else
00033 // Do we have sys/varargs.h?
00034 # ifdef HAVE_SYS_VARARGS_H
00035 #   include <sys/varargs.h>
00036 # else
00037 // We have neither, try the old varargs.h as a last resort and fail
00038 // with compilation errors...
00039 #   warning "stdarg.h not found, compilation will probably fail..."
00040 #   include <varargs.h>
00041 # endif
00042 #endif
00043 
00044 /**************************************************************************
00045  *                                                                        *
00046  *   functions/macros to retreive information about log message sources   *
00047  *                                                                        *
00048  **************************************************************************/
00049 
00050 // predefined sources of logging messages
00051 // Don't forget to update the log_src_info_tab if you change anything!!!
00052 #define PDEPP_CORE         0    
00053 #define QUERY_HANDLER      1    
00054 #define LOGGER             2    
00055 #define CONF_TABLE         3    
00056 #define CONN_HANDLER       4    
00057 #define PROT_HANDLER       5    
00058 #define REQUEST_HANDLER    6    
00059 #define MIME_TABLE         7    
00060 #define LOG_SRC_LAST MIME_TABLE 
00061 
00062 
00064 // it is in fact not unused ;-) but we can avoid some warnings declaring it this way.
00065 __attribute__((unused))
00066 static const char* log_src_info_tab[][2] =
00067   {
00068     {"server core", "S"},
00069     {"dummy", "D"},
00070     {"logger", "L"},
00071     {"configuration data", "F"},
00072     {"connection", "C"},
00073     {"protocol", "P"},
00074     {"requested data", "R"},
00075     {"mime types", "M"}
00076   };
00077 
00079 #define LOG_SRC_PLACEHOLDER_ALL "A"
00080 
00081 // severities of logging messages
00082 #define DEBUG       0           
00083 #define LOG_KEY_DEBUG   "d"     
00084 #define INFO        1           
00085 #define LOG_KEY_INFO    "i"     
00086 #define NOTICE      2           
00087 #define LOG_KEY_NOTICE  "n"     
00088 #define WARNING     3           
00089 #define LOG_KEY_WARNING "w"     
00090 #define ERROR       4           
00091 #define LOG_KEY_ERROR   "e"     
00092 #define CRITICAL    5           
00093 #define LOG_KEY_CRITICAL "c"    
00094 #define LOG_LVL_LAST CRITICAL   
00095 
00097 // it is in fact not unused ;-) but we can avoid some warnings declaring it this way.
00098 __attribute__((unused))
00099 static const char* log_lvl_info_tab[] =
00100   {
00101     LOG_KEY_DEBUG, // these are macros because that is the only way to
00102     LOG_KEY_INFO,  // use these values as string constants with the cpp
00103     LOG_KEY_NOTICE,
00104     LOG_KEY_WARNING,
00105     LOG_KEY_ERROR,
00106     LOG_KEY_CRITICAL
00107   };
00108 
00110 #define LOG_LVL_PLACEHOLDER_ALL "a"
00111 
00112 
00113 // predefined "log files"
00114 #define LOG_NULL_STREAM      "no"         
00115 #define LOG_NULL_FORMAT      "off"        
00116 #define LOG_PANIC_FORMAT     "%h:%m:%s> %S: %L\\n" 
00117 
00118 //MP = Mary Poppins' supercalifragelistigexpialidotious-sign ;)
00119 #define MP '%'          
00120 
00121 #define MP_YEAR    'Y'  
00122 #define MP_MONTH   'M'  
00123 #define MP_DAY     'D'  
00124 #define MP_WDAY    'w'  
00125 #define MP_WDAYL   'W'  
00126 #define MP_HOUR    'h'  
00127 #define MP_MIN     'm'  
00128 #define MP_SEC     's'  
00129 #define MP_SRC     'S'  
00130 #define MP_LOG     'L'  
00131 
00132 #define WD_SHORT 0    
00133 #define WD_LONG  1    
00134 
00136 __attribute__ ((unused))
00137 static const char* day_of_week[][2] =
00138 {
00139   {"Sun", "Sunday"},
00140   {"Mon", "Monday"},
00141   {"Tue", "Tueday"},
00142   {"Wed", "Wednesday"},
00143   {"Thu", "Thursday"},
00144   {"Fri", "Friday"},
00145   {"Sat", "Saturday"}
00146 };
00147 
00148 /**************************************************************************
00149  *                                                                        *
00150  *           functions for dealing with a single logging stream           *
00151  *                                                                        *
00152  **************************************************************************/
00153 /*
00154   each logging stream is associated with exactly ONE log message source
00155   and ONE severity level.
00156  */
00157 
00159 struct Logger;
00161 typedef struct Logger* Logger;
00162 
00163 
00176 Logger logInit(const char * file_name, const char* format);
00177 
00187 Logger logInitStream(FILE * log_stream, const char* format);
00188 
00193 int logMessagev(Logger this,
00194                 const unsigned int origin, const unsigned int severity,
00195                 const int errno_val, const char *const log_text_format, va_list daten);
00196 
00197 
00209 int logTerminate(Logger this);
00210 
00211 /**************************************************************************
00212  *                                                                        *
00213  *           functions for managing a bunch of logging streams            *
00214  *                                                                        *
00215  **************************************************************************/
00216 
00228 int logfilesInit();
00229 
00247 int logerr(const unsigned int source, const unsigned int severity, const int errno_val,
00248          const char *const log_text_format, ...);
00249 
00266 int logger(const unsigned int origin, const unsigned int severity,
00267            const char *const log_text, ...);
00268 
00277 int logfilesTerminate();
00278 
00279 #endif

Generated on Fri Jan 25 22:40:31 2002 for PDepp Webserver by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001