1 #ifndef OSRF_LOG_INCLUDED
2 #define OSRF_LOG_INCLUDED
6 @brief Header for logging routines.
9 #include <opensrf/utils.h>
21 #define OSRF_LOG_ERROR 1
22 #define OSRF_LOG_WARNING 2
23 #define OSRF_LOG_INFO 3
24 #define OSRF_LOG_DEBUG 4
25 #define OSRF_LOG_INTERNAL 5
26 #define OSRF_LOG_ACTIVITY -1
28 #define OSRF_LOG_TYPE_FILE 1
29 #define OSRF_LOG_TYPE_SYSLOG 2
30 #define OSRF_LOG_TYPE_STDERR 3
32 #define OSRF_LOG_MARK __FILE__, __LINE__
35 /* Initializes the logger. */
36 void osrfLogInit( int type, const char* appname, int maxlevel );
38 /** Sets the systlog facility for the regular logs */
39 void osrfLogSetSyslogFacility( int facility );
41 /** Sets the systlog facility for the activity logs */
42 void osrfLogSetSyslogActFacility( int facility );
44 /** Reroutes logged messages to standard error; */
45 /** intended for development and debugging */
46 void osrfLogToStderr( void );
48 /** Undoes the effects of osrfLogToStderr() */
49 void osrfRestoreLogType( void );
51 /** Sets the log file to use if we're logging to a file */
52 void osrfLogSetFile( const char* logfile );
54 /* once we know which application we're running, call this method to
55 * set the appname so log lines can include the app name */
56 void osrfLogSetAppname( const char* appname );
58 /** Set or Get the global log level. Any log statements with a higher level
59 * than "level" will not be logged */
60 void osrfLogSetLevel( int loglevel );
61 int osrfLogGetLevel( void );
63 /* Log an error message */
64 void osrfLogError( const char* file, int line, const char* msg, ... );
66 /* Log a warning message */
67 void osrfLogWarning( const char* file, int line, const char* msg, ... );
69 /* log an info message */
70 void osrfLogInfo( const char* file, int line, const char* msg, ... );
72 /* Log a debug message */
73 void osrfLogDebug( const char* file, int line, const char* msg, ... );
75 /* Log an internal debug message */
76 void osrfLogInternal( const char* file, int line, const char* msg, ... );
78 /* Log an activity message */
79 void osrfLogActivity( const char* file, int line, const char* msg, ... );
81 void osrfLogCleanup( void );
83 void osrfLogClearXid( void );
85 * Set the log XID. This only sets the xid if we are not the origin client
87 void osrfLogSetXid(char* xid);
89 * Set the log XID regardless of whether we are the origin client
91 void osrfLogForceXid(char* xid);
92 void osrfLogMkXid( void );
93 void osrfLogSetIsClient(int is);
94 const char* osrfLogGetXid( void );
96 /* sets the activity flag */
97 void osrfLogSetActivityEnabled( int enabled );
99 /* returns the int representation of the log facility based on the facility name
100 * if the facility name is invalid, LOG_LOCAL0 is returned
102 int osrfLogFacilityToInt( const char* facility );