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 /** Sets the log file to use if we're logging to a file */
36 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 );
42 /** Set or Get the global log level. Any log statements with a higher level
43 * than "level" will not be logged */
44 void osrfLogSetLevel( int loglevel );
45 int osrfLogGetLevel( void );
47 /* Log an error message */
48 void osrfLogError( const char* file, int line, const char* msg, ... );
50 /* Log a warning message */
51 void osrfLogWarning( const char* file, int line, const char* msg, ... );
53 /* log an info message */
54 void osrfLogInfo( const char* file, int line, const char* msg, ... );
56 /* Log a debug message */
57 void osrfLogDebug( const char* file, int line, const char* msg, ... );
59 /* Log an internal debug message */
60 void osrfLogInternal( const char* file, int line, const char* msg, ... );
62 /* Log an activity message */
63 void osrfLogActivity( const char* file, int line, const char* msg, ... );
65 void osrfLogCleanup();
67 void osrfLogClearXid();
68 void osrfLogSetXid(char* xid);
70 void osrfLogSetIsClient(int is);
71 char* osrfLogGetXid();
73 /* sets the activity flag */
74 void osrfLogSetActivityEnabled( int enabled );
76 /* returns the int representation of the log facility based on the facility name
77 * if the facility name is invalid, LOG_LOCAL0 is returned
79 int osrfLogFacilityToInt( char* facility );