]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/log.h
4aafad39d7523c4c199e2b89f4417591d4a81c49
[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
22 #define OSRF_LOG_MARK __FILE__, __LINE__
23
24
25 /* Initializes the logger. */
26 void osrfLogInit( int type, const char* appname, int maxlevel );
27
28 /** Sets the systlog facility for the regular logs */
29 void osrfLogSetSyslogFacility( int facility );
30
31 /** Sets the systlog facility for the activity logs */
32 void osrfLogSetSyslogActFacility( int facility );
33
34 /** Sets the log file to use if we're logging to a file */
35 void osrfLogSetFile( const char* logfile );
36
37 /* once we know which application we're running, call this method to
38  * set the appname so log lines can include the app name */
39 void osrfLogSetAppname( const char* appname );
40
41 /** Set or Get the global log level.  Any log statements with a higher level
42  * than "level" will not be logged */
43 void osrfLogSetLevel( int loglevel );
44 int osrfLogGetLevel( void );
45
46 /* Log an error message */
47 void osrfLogError( const char* file, int line, const char* msg, ... );
48
49 /* Log a warning message */
50 void osrfLogWarning( const char* file, int line, const char* msg, ... );
51
52 /* log an info message */
53 void osrfLogInfo( const char* file, int line, const char* msg, ... );
54
55 /* Log a debug message */
56 void osrfLogDebug( const char* file, int line, const char* msg, ... );
57
58 /* Log an internal debug message */
59 void osrfLogInternal( const char* file, int line, const char* msg, ... );
60
61 /* Log an activity message */
62 void osrfLogActivity( const char* file, int line, const char* msg, ... );
63
64 void osrfLogCleanup();
65
66 void osrfLogClearXid();
67 void osrfLogSetXid(char* xid);
68 void osrfLogMkXid();
69 void osrfLogSetIsClient(int is);
70 char* osrfLogGetXid();
71
72 /* sets the activity flag */
73 void osrfLogSetActivityEnabled( int enabled );
74
75 /* returns the int representation of the log facility based on the facility name
76  * if the facility name is invalid, LOG_LOCAL0 is returned 
77  */
78 int osrfLogFacilityToInt( char* facility );
79
80 #endif