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
22 #define OSRF_LOG_MARK __FILE__, __LINE__
25 /* Initializes the logger. */
26 void osrfLogInit( int type, const char* appname, int maxlevel );
28 /** Sets the systlog facility for the regular logs */
29 void osrfLogSetSyslogFacility( int facility );
31 /** Sets the systlog facility for the activity logs */
32 void osrfLogSetSyslogActFacility( int facility );
34 /** Sets the log file to use if we're logging to a file */
35 void osrfLogSetFile( const char* logfile );
37 /* once we know which application we're running, call this method to
38 * set the appname so log lines can include the app name */
39 void osrfLogSetAppname( const char* appname );
41 /** Set or Get the global log level. Any log statements with a higher level
42 * than "level" will not be logged */
43 void osrfLogSetLevel( int loglevel );
44 int osrfLogGetLevel( void );
46 /* Log an error message */
47 void osrfLogError( const char* file, int line, const char* msg, ... );
49 /* Log a warning message */
50 void osrfLogWarning( const char* file, int line, const char* msg, ... );
52 /* log an info message */
53 void osrfLogInfo( const char* file, int line, const char* msg, ... );
55 /* Log a debug message */
56 void osrfLogDebug( const char* file, int line, const char* msg, ... );
58 /* Log an internal debug message */
59 void osrfLogInternal( const char* file, int line, const char* msg, ... );
61 /* Log an activity message */
62 void osrfLogActivity( const char* file, int line, const char* msg, ... );
64 void osrfLogCleanup();
66 void osrfLogClearXid();
67 void osrfLogSetXid(char* xid);
69 void osrfLogSetIsClient(int is);
70 char* osrfLogGetXid();
72 /* sets the activity flag */
73 void osrfLogSetActivityEnabled( int enabled );
75 /* returns the int representation of the log facility based on the facility name
76 * if the facility name is invalid, LOG_LOCAL0 is returned
78 int osrfLogFacilityToInt( char* facility );