Main Page | Class List | File List | Class Members | File Members | Related Pages

gi_log.h File Reference

High-level logging interface capable used directly by giftd and indirectly (through libgiftproto) by plugins. More...

Go to the source code of this file.

Log domains.

#define GI_LOG_FATAL   (0x01)
#define GI_LOG_EMERG   (0x02)
#define GI_LOG_ERROR   (0x04)
#define GI_LOG_WARNING   (0x08)
#define GI_LOG_DEBUG   (0x20)
#define GI_LOG_DEPRECATED   (0x100)
#define GI_LOG_ALL   (0x13f)
#define GI_LOG_NONE   (0x00)

Log output methods and options.

#define GI_LOG_STDOUT   (0x01)
#define GI_LOG_STDERR   (0x02)
#define GI_LOG_TIMESTAMP   (0x20) /* prepend a timestamp to each msg */
#define GI_LOG_NODOMAINPFX   (0x40)
#define GI_PRINTF_ATTR(f, v)
#define GI_LOG_WRAPPER(__funcfn__)
#define __FUNCTION__   __func__
#define GI_TRACE   __FILE__, __LINE__, __FUNCTION__
#define GI_TRACEL   __FILE__, 0, NULL
#define gi_log_debug   gi_log_simple
#define gi_log_message   gi_log_simple
EXTERN_C_BEGIN LIBGIFT_EXPORT
void 
gi_log_init (const char *ident, int output, int domain_mask, int level)
LIBGIFT_EXPORT void gi_log_finish (void)
LIBGIFT_EXPORT FILE * gi_log_open (const char *pathname)
LIBGIFT_EXPORT void gi_log_close (FILE *f)
LIBGIFT_EXPORT int gi_log_vprintf (const char *file, unsigned int line, const char *funcname, int domain, int level, const char *fmt, va_list args)
LIBGIFT_EXPORT int gi_log_printf (int domain, int level, const char *fmt,...)
 GI_LOG_WRAPPER (gi_log_simple)
 GI_LOG_WRAPPER (gi_log_warning)
 GI_LOG_WRAPPER (gi_log_error)
 GI_LOG_WRAPPER (gi_log_emerg)
 GI_LOG_WRAPPER (gi_log_fatal)
LIBGIFT_EXPORT int gi_log_debugfn (const char *file, unsigned int line, const char *funcname, int level, const char *fmt,...) GI_PRINTF_ATTR(5


Detailed Description

High-level logging interface capable used directly by giftd and indirectly (through libgiftproto) by plugins.


Define Documentation

#define GI_LOG_WRAPPER __funcfn__   ) 
 

Value:

LIBGIFT_EXPORT \ int __funcfn__ (int level, const char *fmt, ...) \ GI_PRINTF_ATTR (2, 3)
Wrapper for gi_log_vprintf which pass the appropriate domain parameter. This is used to produce the prototypes for gi_log_debug, error, etc, and is not intended to be used directly by the user under any circumstance.


Function Documentation

LIBGIFT_EXPORT void gi_log_close FILE *  f  ) 
 

Explicitly close a previously opened log output stream. If you wish to close down all opened log output channels at once, use gi_log_finish.

LIBGIFT_EXPORT int gi_log_debugfn const char *  file,
unsigned int  line,
const char *  funcname,
int  level,
const char *  fmt,
  ...
 

Special logging facility which adds source trace information (file, line and function) from the caller. Usage of this function should be through the ::gi_log_debug macro, which guarantees that this interface works correctly on C99-compliant hosts, as well as GNU C. Other platforms will simply replace usage of ::gi_log_debug with ::gi_log_message.

LIBGIFT_EXPORT void gi_log_finish void   ) 
 

Shut down the logging facility and cleanup any opened output streams. This includes streams opened through the gi_log_open interface.

EXTERN_C_BEGIN LIBGIFT_EXPORT void gi_log_init const char *  ident,
int  output,
int  domain_mask,
int  level
 

Initialize the logging facilities and open the requested output streams if applicable.

Parameters:
ident The current application's identification. This is simply a string constant that will be appended to the beginning of every message for certain logging facilities.
output Specifies the output channels to use, if any. Additionally, this parameter may be used to specify certain logging options, such as timestamping. If you use GI_LOG_FILE, you must follow this call with at least one ::gi_log_openfile request.
domain_mask Mask applied to every log message sent to this system. If the result after the mask is 0, the log message will be discarded. Every log domain may be OR'd together to produce the desired domain mask. For example, GI_LOG_ERROR | GI_LOG_EMERG will log only error and emergency messages.
level Verbosity level to filter out "noisy" log messages. Only log requests which are at or below this value will be displayed to the message. This applies to all log domains.

LIBGIFT_EXPORT FILE* gi_log_open const char *  pathname  ) 
 

Open a log output channel through fopen after initialization. No special opens must be used for the `output' during gi_log_init. The file described by `pathname' will be created if it doesn't exist, and will be truncated if it does.

LIBGIFT_EXPORT int gi_log_printf int  domain,
int  level,
const char *  fmt,
  ...
 

Wrapper for gi_log_vprintf.

LIBGIFT_EXPORT int gi_log_vprintf const char *  file,
unsigned int  line,
const char *  funcname,
int  domain,
int  level,
const char *  fmt,
va_list  args
 

Write the log message through the vprintf family of functions. This is the primary logging interface, to which all other interfaces act as mere wrappers.

Parameters:
file This is provided for ::gi_log_debug only. Use NULL if attempting manual usage.
line This is provided for ::gi_log_debug only. Use 0 if attempting manual usage.
funcname This is provided for :;gi_log_debug only. Use NULL if attempting manual usage.

Parameters:
domain Specifies the domain which this message exists in. In other words, the type of log message, such as GI_LOG_ERROR, GI_LOG_WARNING, GI_LOG_DEBUG, etc. If the log was opened with a domain mask which does not include the domain value specified here, the message will be dropped.
level Message verbosity. This level should represent a gradient scale of importance and/or priority that this message is displayed to the user. If the number is above the initialized level (see gi_log_open), it will be dropped.
fmt Format string to be passed directly to the vprintf family of functions.
args Format parameters.
Returns:
On success, the number of characters written to the log as a positive non-zero integer. If an error occurs, or the message is dropped according to the log domain or level, the return value will be -1 or 0 respectively, and no log message will have been written.


Generated on Sun Aug 22 07:56:40 2004 by doxygen 1.3.7