1 #include <opensrf/utils.h>
8 #ifndef OSRF_LOG_INCLUDED
9 #define OSRF_LOG_INCLUDED
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
19 #define OSRF_LOG_TYPE_FILE 1
20 #define OSRF_LOG_TYPE_SYSLOG 2
21 #define OSRF_LOG_TYPE_STDERR 3
23 #define OSRF_LOG_MARK __FILE__, __LINE__
26 /* Initializes the logger. */
27 void osrfLogInit( int type, const char* appname, int maxlevel );
29 /** Sets the systlog facility for the regular logs */
30 void osrfLogSetSyslogFacility( int facility );
32 /** Sets the systlog facility for the activity logs */
33 void osrfLogSetSyslogActFacility( int facility );
35 /** Reroutes logged messages to standard error; */
36 /** intended for development and debugging */
37 void osrfLogToStderr( void );
39 /** Undoes the effects of osrfLogToStderr() */
40 void osrfRestoreLogType( void );
42 /** Sets the log file to use if we're logging to a file */
43 void osrfLogSetFile( const char* logfile );
45 /* once we know which application we're running, call this method to
46 * set the appname so log lines can include the app name */
47 void osrfLogSetAppname( const char* appname );
49 /** Set or Get the global log level. Any log statements with a higher level
50 * than "level" will not be logged */
51 void osrfLogSetLevel( int loglevel );
52 int osrfLogGetLevel( void );
54 /* Log an error message */
55 void osrfLogError( const char* file, int line, const char* msg, ... );
57 /* Log a warning message */
58 void osrfLogWarning( const char* file, int line, const char* msg, ... );
60 /* log an info message */
61 void osrfLogInfo( const char* file, int line, const char* msg, ... );
63 /* Log a debug message */
64 void osrfLogDebug( const char* file, int line, const char* msg, ... );
66 /* Log an internal debug message */
67 void osrfLogInternal( const char* file, int line, const char* msg, ... );
69 /* Log an activity message */
70 void osrfLogActivity( const char* file, int line, const char* msg, ... );
72 void osrfLogCleanup( void );
74 void osrfLogClearXid( void );
75 void osrfLogSetXid(char* xid);
76 void osrfLogMkXid( void );
77 void osrfLogSetIsClient(int is);
78 char* osrfLogGetXid( void );
80 /* sets the activity flag */
81 void osrfLogSetActivityEnabled( int enabled );
83 /* returns the int representation of the log facility based on the facility name
84 * if the facility name is invalid, LOG_LOCAL0 is returned
86 int osrfLogFacilityToInt( char* facility );