]> git.evergreen-ils.org Git - Evergreen.git/blob - OpenSRF/src/utils/log.h
moved C code to a unified logging framework which currently supports syslogging and...
[Evergreen.git] / OpenSRF / src / utils / log.h
1 #include <syslog.h>
2 #include <stdio.h>
3 #include "utils.h"
4 #include <time.h>
5
6 #ifndef OSRF_LOG_INCLUDED
7 #define OSRF_LOG_INCLUDED
8
9 /* log levels */
10 #define OSRF_LOG_ERROR 1
11 #define OSRF_LOG_WARNING 2
12 #define OSRF_LOG_INFO 3
13 #define OSRF_LOG_DEBUG 4
14 #define OSRF_LOG_INTERNAL 5
15 #define OSRF_LOG_ACTIVITY -1
16
17 #define OSRF_LOG_TYPE_FILE 1
18 #define OSRF_LOG_TYPE_SYSLOG 2
19
20
21 #define OSRF_LOG_GO(m,l)                \
22         if(!m) return;                                  \
23         VA_LIST_TO_STRING(m);           \
24         osrfLogDetail( l, NULL, -1, NULL, VA_BUF );
25         
26
27
28 /* Initializes the logger. */
29 void osrfLogInit( int type, const char* appname, int maxlevel );
30 /** Sets the type of logging to perform.  See log types */
31 void osrfLogSetType( int logtype );
32 /** Sets the systlog facility for the regular logs */
33 void osrfLogSetSyslogFacility( int facility );
34 /** Sets the systlog facility for the activity logs */
35 void osrfLogSetSyslogActFacility( int facility );
36 /** Sets the log file to use if we're logging to a file */
37 void osrfLogSetFile( const char* logfile );
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 /** Sets the global log level.  Any log statements with a higher level
42  * than "level" will not be logged */
43 void osrfLogSetLevel( int loglevel );
44 /* Log an error message */
45 void osrfLogError( const char* msg, ... );
46 /* Log a warning message */
47 void osrfLogWarning( const char* msg, ... );
48 /* log an info message */
49 void osrfLogInfo( const char* msg, ... );
50 /* Log a debug message */
51 void osrfLogDebug( const char* msg, ... );
52 /* Log an internal debug message */
53 void osrfLogInternal( const char* msg, ... );
54 /* Log an activity message */
55 void osrfLogActivity( const char* msg, ... );
56
57 void osrfLogSetActivityEnabled( int enabled );
58
59 /* Use this for logging detailed message containing the filename, line number
60  * and function name in addition to the usual level and message */
61 void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, ... );
62
63 void _osrfLogToFile( char* msg, ... );
64
65 int osrfLogFacilityToInt( char* facility );
66
67 #endif