]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/log.h
1. A minor streamlining of va_list_to_string(), to eliminate
[OpenSRF.git] / include / opensrf / log.h
1 #ifndef OSRF_LOG_INCLUDED
2 #define OSRF_LOG_INCLUDED
3
4 #include <opensrf/utils.h>
5
6 #include <syslog.h>
7 #include <stdio.h>
8 #include <time.h>
9 #include <errno.h>
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 /* log levels */
16 #define OSRF_LOG_ERROR 1
17 #define OSRF_LOG_WARNING 2
18 #define OSRF_LOG_INFO 3
19 #define OSRF_LOG_DEBUG 4
20 #define OSRF_LOG_INTERNAL 5
21 #define OSRF_LOG_ACTIVITY -1
22
23 #define OSRF_LOG_TYPE_FILE 1
24 #define OSRF_LOG_TYPE_SYSLOG 2
25 #define OSRF_LOG_TYPE_STDERR 3
26
27 #define OSRF_LOG_MARK __FILE__, __LINE__
28
29
30 /* Initializes the logger. */
31 void osrfLogInit( int type, const char* appname, int maxlevel );
32
33 /** Sets the systlog facility for the regular logs */
34 void osrfLogSetSyslogFacility( int facility );
35
36 /** Sets the systlog facility for the activity logs */
37 void osrfLogSetSyslogActFacility( int facility );
38
39 /** Reroutes logged messages to standard error; */
40 /** intended for development and debugging */
41 void osrfLogToStderr( void );
42
43 /** Undoes the effects of osrfLogToStderr() */
44 void osrfRestoreLogType( void );
45
46 /** Sets the log file to use if we're logging to a file */
47 void osrfLogSetFile( const char* logfile );
48
49 /* once we know which application we're running, call this method to
50  * set the appname so log lines can include the app name */
51 void osrfLogSetAppname( const char* appname );
52
53 /** Set or Get the global log level.  Any log statements with a higher level
54  * than "level" will not be logged */
55 void osrfLogSetLevel( int loglevel );
56 int osrfLogGetLevel( void );
57
58 /* Log an error message */
59 void osrfLogError( const char* file, int line, const char* msg, ... );
60
61 /* Log a warning message */
62 void osrfLogWarning( const char* file, int line, const char* msg, ... );
63
64 /* log an info message */
65 void osrfLogInfo( const char* file, int line, const char* msg, ... );
66
67 /* Log a debug message */
68 void osrfLogDebug( const char* file, int line, const char* msg, ... );
69
70 /* Log an internal debug message */
71 void osrfLogInternal( const char* file, int line, const char* msg, ... );
72
73 /* Log an activity message */
74 void osrfLogActivity( const char* file, int line, const char* msg, ... );
75
76 void osrfLogCleanup( void );
77
78 void osrfLogClearXid( void );
79 /**
80  * Set the log XID.  This only sets the xid if we are not the origin client 
81  */
82 void osrfLogSetXid(char* xid);
83 /**
84  * Set the log XID regardless of whether we are the origin client
85  */
86 void osrfLogForceXid(char* xid);
87 void osrfLogMkXid( void );
88 void osrfLogSetIsClient(int is);
89 char* osrfLogGetXid( void );
90
91 /* sets the activity flag */
92 void osrfLogSetActivityEnabled( int enabled );
93
94 /* returns the int representation of the log facility based on the facility name
95  * if the facility name is invalid, LOG_LOCAL0 is returned 
96  */
97 int osrfLogFacilityToInt( char* facility );
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103 #endif