1 #ifndef OSRF_LOG_INCLUDED
2 #define OSRF_LOG_INCLUDED
4 #include <opensrf/utils.h>
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
23 #define OSRF_LOG_TYPE_FILE 1
24 #define OSRF_LOG_TYPE_SYSLOG 2
25 #define OSRF_LOG_TYPE_STDERR 3
27 #define OSRF_LOG_MARK __FILE__, __LINE__
30 /* Initializes the logger. */
31 void osrfLogInit( int type, const char* appname, int maxlevel );
33 /** Sets the systlog facility for the regular logs */
34 void osrfLogSetSyslogFacility( int facility );
36 /** Sets the systlog facility for the activity logs */
37 void osrfLogSetSyslogActFacility( int facility );
39 /** Reroutes logged messages to standard error; */
40 /** intended for development and debugging */
41 void osrfLogToStderr( void );
43 /** Undoes the effects of osrfLogToStderr() */
44 void osrfRestoreLogType( void );
46 /** Sets the log file to use if we're logging to a file */
47 void osrfLogSetFile( const char* logfile );
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 );
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 );
58 /* Log an error message */
59 void osrfLogError( const char* file, int line, const char* msg, ... );
61 /* Log a warning message */
62 void osrfLogWarning( const char* file, int line, const char* msg, ... );
64 /* log an info message */
65 void osrfLogInfo( const char* file, int line, const char* msg, ... );
67 /* Log a debug message */
68 void osrfLogDebug( const char* file, int line, const char* msg, ... );
70 /* Log an internal debug message */
71 void osrfLogInternal( const char* file, int line, const char* msg, ... );
73 /* Log an activity message */
74 void osrfLogActivity( const char* file, int line, const char* msg, ... );
76 void osrfLogCleanup( void );
78 void osrfLogClearXid( void );
80 * Set the log XID. This only sets the xid if we are not the origin client
82 void osrfLogSetXid(char* xid);
84 * Set the log XID regardless of whether we are the origin client
86 void osrfLogForceXid(char* xid);
87 void osrfLogMkXid( void );
88 void osrfLogSetIsClient(int is);
89 char* osrfLogGetXid( void );
91 /* sets the activity flag */
92 void osrfLogSetActivityEnabled( int enabled );
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
97 int osrfLogFacilityToInt( char* facility );