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