]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/log.h
Patch from Scott McKellar to improve default logging:
[OpenSRF.git] / include / opensrf / log.h
1 #include <opensrf/utils.h>
2
3 #include <syslog.h>
4 #include <stdio.h>
5 #include <time.h>
6 #include <errno.h>
7
8 #ifndef OSRF_LOG_INCLUDED
9 #define OSRF_LOG_INCLUDED
10
11 /* log levels */
12 #define OSRF_LOG_ERROR 1
13 #define OSRF_LOG_WARNING 2
14 #define OSRF_LOG_INFO 3
15 #define OSRF_LOG_DEBUG 4
16 #define OSRF_LOG_INTERNAL 5
17 #define OSRF_LOG_ACTIVITY -1
18
19 #define OSRF_LOG_TYPE_FILE 1
20 #define OSRF_LOG_TYPE_SYSLOG 2
21 #define OSRF_LOG_TYPE_STDERR 3
22
23 #define OSRF_LOG_MARK __FILE__, __LINE__
24
25
26 /* Initializes the logger. */
27 void osrfLogInit( int type, const char* appname, int maxlevel );
28
29 /** Sets the systlog facility for the regular logs */
30 void osrfLogSetSyslogFacility( int facility );
31
32 /** Sets the systlog facility for the activity logs */
33 void osrfLogSetSyslogActFacility( int facility );
34
35 /** Sets the log file to use if we're logging to a file */
36 void osrfLogSetFile( const char* logfile );
37
38 /* once we know which application we're running, call this method to
39  * set the appname so log lines can include the app name */
40 void osrfLogSetAppname( const char* appname );
41
42 /** Set or Get the global log level.  Any log statements with a higher level
43  * than "level" will not be logged */
44 void osrfLogSetLevel( int loglevel );
45 int osrfLogGetLevel( void );
46
47 /* Log an error message */
48 void osrfLogError( const char* file, int line, const char* msg, ... );
49
50 /* Log a warning message */
51 void osrfLogWarning( const char* file, int line, const char* msg, ... );
52
53 /* log an info message */
54 void osrfLogInfo( const char* file, int line, const char* msg, ... );
55
56 /* Log a debug message */
57 void osrfLogDebug( const char* file, int line, const char* msg, ... );
58
59 /* Log an internal debug message */
60 void osrfLogInternal( const char* file, int line, const char* msg, ... );
61
62 /* Log an activity message */
63 void osrfLogActivity( const char* file, int line, const char* msg, ... );
64
65 void osrfLogCleanup();
66
67 void osrfLogClearXid();
68 void osrfLogSetXid(char* xid);
69 void osrfLogMkXid();
70 void osrfLogSetIsClient(int is);
71 char* osrfLogGetXid();
72
73 /* sets the activity flag */
74 void osrfLogSetActivityEnabled( int enabled );
75
76 /* returns the int representation of the log facility based on the facility name
77  * if the facility name is invalid, LOG_LOCAL0 is returned 
78  */
79 int osrfLogFacilityToInt( char* facility );
80
81 #endif