]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/utils/log.h
61f59f3a9082f4e6dabe1fad8202753d9a5df9f2
[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 #define OSRF_LOG_MARK __FILE__, __LINE__
22
23
24 #define OSRF_LOG_GO(f,li,m,l)           \
25         if(!m) return;                                  \
26         VA_LIST_TO_STRING(m);           \
27         _osrfLogDetail( l, f, li, VA_BUF );
28         
29
30
31 /* Initializes the logger. */
32 void osrfLogInit( int type, const char* appname, int maxlevel );
33 /** Sets the type of logging to perform.  See log types */
34 void osrfLogSetType( int logtype );
35 /** Sets the systlog facility for the regular logs */
36 void osrfLogSetSyslogFacility( int facility );
37 /** Sets the systlog facility for the activity logs */
38 void osrfLogSetSyslogActFacility( int facility );
39 /** Sets the log file to use if we're logging to a file */
40 void osrfLogSetFile( const char* logfile );
41 /* once we know which application we're running, call this method to
42  * set the appname so log lines can include the app name */
43 void osrfLogSetAppname( const char* appname );
44 /** Sets the global log level.  Any log statements with a higher level
45  * than "level" will not be logged */
46 void osrfLogSetLevel( int loglevel );
47 /* Log an error message */
48 void osrfLogError( const char* file, int line, const char* msg, ... );
49 /* Log a warning message */
50 void osrfLogWarning( const char* file, int line, const char* msg, ... );
51 /* log an info message */
52 void osrfLogInfo( const char* file, int line, const char* msg, ... );
53 /* Log a debug message */
54 void osrfLogDebug( const char* file, int line, const char* msg, ... );
55 /* Log an internal debug message */
56 void osrfLogInternal( const char* file, int line, const char* msg, ... );
57 /* Log an activity message */
58 void osrfLogActivity( const char* file, int line, const char* msg, ... );
59
60 /* sets the activity flag */
61 void osrfLogSetActivityEnabled( int enabled );
62
63 /** Actually does the logging */
64 void _osrfLogDetail( int level, const char* filename, int line, char* msg );
65
66 void _osrfLogToFile( char* msg, ... );
67
68 /* returns the int representation of the log facility based on the facility name
69  * if the facility name is invalid, LOG_LOCAL0 is returned 
70  */
71 int osrfLogFacilityToInt( char* facility );
72
73 #endif