]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/utils/log.h
added some log statements, fixed some typos
[OpenSRF.git] / src / utils / log.h
1 #include <syslog.h>
2 #include <stdio.h>
3 #include "utils.h"
4 #include <time.h>
5 #include <errno.h>
6
7 #ifndef OSRF_LOG_INCLUDED
8 #define OSRF_LOG_INCLUDED
9
10 /* log levels */
11 #define OSRF_LOG_ERROR 1
12 #define OSRF_LOG_WARNING 2
13 #define OSRF_LOG_INFO 3
14 #define OSRF_LOG_DEBUG 4
15 #define OSRF_LOG_INTERNAL 5
16 #define OSRF_LOG_ACTIVITY -1
17
18 #define OSRF_LOG_TYPE_FILE 1
19 #define OSRF_LOG_TYPE_SYSLOG 2
20
21
22 #define OSRF_LOG_GO(m,l)                \
23         if(!m) return;                                  \
24         VA_LIST_TO_STRING(m);           \
25         osrfLogDetail( l, NULL, -1, NULL, VA_BUF );
26         
27
28
29 /* Initializes the logger. */
30 void osrfLogInit( int type, const char* appname, int maxlevel );
31 /** Sets the type of logging to perform.  See log types */
32 void osrfLogSetType( int logtype );
33 /** Sets the systlog facility for the regular logs */
34 void osrfLogSetSyslogFacility( int facility );
35 /** Sets the systlog facility for the activity logs */
36 void osrfLogSetSyslogActFacility( int facility );
37 /** Sets the log file to use if we're logging to a file */
38 void osrfLogSetFile( const char* logfile );
39 /* once we know which application we're running, call this method to
40  * set the appname so log lines can include the app name */
41 void osrfLogSetAppname( const char* appname );
42 /** Sets the global log level.  Any log statements with a higher level
43  * than "level" will not be logged */
44 void osrfLogSetLevel( int loglevel );
45 /* Log an error message */
46 void osrfLogError( const char* msg, ... );
47 /* Log a warning message */
48 void osrfLogWarning( const char* msg, ... );
49 /* log an info message */
50 void osrfLogInfo( const char* msg, ... );
51 /* Log a debug message */
52 void osrfLogDebug( const char* msg, ... );
53 /* Log an internal debug message */
54 void osrfLogInternal( const char* msg, ... );
55 /* Log an activity message */
56 void osrfLogActivity( const char* msg, ... );
57
58 void osrfLogSetActivityEnabled( int enabled );
59
60 /* Use this for logging detailed message containing the filename, line number
61  * and function name in addition to the usual level and message */
62 void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, ... );
63
64 void _osrfLogToFile( char* msg, ... );
65
66 /* returns the int representation of the log facility based on the facility name
67  * if the facility name is invalid, LOG_LOCAL0 is returned 
68  */
69 int osrfLogFacilityToInt( char* facility );
70
71 #endif