log.h File Reference

Logging utility. More...

#include <stdio.h>
#include <yaz/yconfig.h>

Go to the source code of this file.

Defines

#define YLOG_FATAL   0x00000001
 log level: fatal
#define YLOG_DEBUG   0x00000002
 log level: debugging
#define YLOG_WARN   0x00000004
 log level: warning
#define YLOG_LOG   0x00000008
 log level: log (regular)
#define YLOG_ERRNO   0x00000010
 log level: append system error message
#define YLOG_APP   0x00000040
 log level: application
#define YLOG_MALLOC   0x00000080
 log level: malloc debug
#define YLOG_NOTIME   0x00000100
 log level: do not output date and time
#define YLOG_APP2   0x00000200
 log level: application 2
#define YLOG_APP3   0x00000400
 log level: application 3
#define YLOG_FLUSH   0x00000800
 log level: flush
#define YLOG_LOGLVL   0x00001000
 dynamic log level start
#define YLOG_ALL   (0xffff&~YLOG_MALLOC&~YLOG_NOTIME)
#define YLOG_DEFAULT_LEVEL   (YLOG_FATAL | YLOG_ERRNO | YLOG_LOG | YLOG_WARN | YLOG_FLUSH)
 default log level
#define YLOG_LAST_BIT   YLOG_LOGLVL
 last bit for regular log bits . Rest are dynamic
#define YAZ_USE_NEW_LOG   1

Functions

void yaz_log_init (int level, const char *prefix, const char *fname)
 sets level, prefix and filename for logging
void yaz_log_init_file (const char *fname)
 sets log to a file
void yaz_log_init_level (int level)
 sets log level
void yaz_log_init_prefix (const char *prefix)
 sets log message prefix
void yaz_log_init_prefix2 (const char *prefix)
 sets second log message prefix
void yaz_log_time_format (const char *fmt)
 sets time format for log mesages
void yaz_log_init_max_size (int mx)
 sets limit in bytes for size for log file
void yaz_log (int level, const char *fmt,...)
 Writes log message.
int yaz_log_mask_str (const char *str)
 converts log level string to log level (integer)
int yaz_log_mask_str_x (const char *str, int level)
 converts log level string to log level with "start" level
int yaz_log_module_level (const char *name)
 returns level for module
FILE * yaz_log_file (void)
 returns FILE handle for log or NULL if no file is in use
void yaz_log_set_handler (void(*func)(int, const char *, void *), void *info)
 sets custom log handler
void yaz_log_reopen (void)
void yaz_log_trunc (void)
 Truncate the log file.
void log_event_start (void(*func)(int level, const char *msg, void *info), void *info)
void log_event_end (void(*func)(int level, const char *msg, void *info), void *info)
void yaz_log_xml_errors (const char *prefix, int log_level)
 Makes Libxml2/Libxslt log errors via yaz_log.


Detailed Description

Logging utility.

Definition in file log.h.


Define Documentation

#define YAZ_USE_NEW_LOG   1

Definition at line 207 of file log.h.

#define YLOG_ALL   (0xffff&~YLOG_MALLOC&~YLOG_NOTIME)

Definition at line 67 of file log.h.

#define YLOG_APP   0x00000040

log level: application

Definition at line 52 of file log.h.

#define YLOG_APP2   0x00000200

log level: application 2

Definition at line 58 of file log.h.

#define YLOG_APP3   0x00000400

log level: application 3

Definition at line 60 of file log.h.

#define YLOG_DEBUG   0x00000002

log level: debugging

Definition at line 44 of file log.h.

Referenced by backend_response(), check_ip_tcpd(), control_association(), ir_read(), and ir_session().

#define YLOG_DEFAULT_LEVEL   (YLOG_FATAL | YLOG_ERRNO | YLOG_LOG | YLOG_WARN | YLOG_FLUSH)

default log level

Definition at line 70 of file log.h.

#define YLOG_ERRNO   0x00000010

log level: append system error message

Definition at line 50 of file log.h.

Referenced by create_association(), readconf(), xrealloc_f(), yaz_daemon(), yaz_log(), and yaz_sc_program().

#define YLOG_FATAL   0x00000001

log level: fatal

Definition at line 42 of file log.h.

Referenced by backend_response(), nmem_malloc(), xcalloc_f(), xmalloc_f(), xrealloc_f(), yaz_daemon(), and yaz_sc_program().

#define YLOG_FLUSH   0x00000800

log level: flush

Definition at line 62 of file log.h.

Referenced by yaz_log_init_level().

#define YLOG_LAST_BIT   YLOG_LOGLVL

last bit for regular log bits . Rest are dynamic

Definition at line 76 of file log.h.

Referenced by yaz_log_init_level().

#define YLOG_LOG   0x00000008

#define YLOG_LOGLVL   0x00001000

dynamic log level start

Definition at line 64 of file log.h.

Referenced by yaz_log_init_level(), and yaz_log_module_level().

#define YLOG_MALLOC   0x00000080

log level: malloc debug

Definition at line 54 of file log.h.

#define YLOG_NOTIME   0x00000100

log level: do not output date and time

Definition at line 56 of file log.h.

#define YLOG_WARN   0x00000004


Function Documentation

void log_event_end ( void(*)(int level, const char *msg, void *info)  func,
void *  info 
)

void log_event_start ( void(*)(int level, const char *msg, void *info)  func,
void *  info 
)

void yaz_log ( int  level,
const char *  fmt,
  ... 
)

FILE* yaz_log_file ( void   ) 

returns FILE handle for log or NULL if no file is in use

Return values:
FILE FILE handle in use
NULL log is currently not written to a file

Definition at line 120 of file log.c.

References use_file, use_none, and use_stderr.

Referenced by create_association(), ir_read(), yaz_log(), and ztest_esrequest().

void yaz_log_init ( int  level,
const char *  prefix,
const char *  fname 
)

sets level, prefix and filename for logging

Parameters:
level log level
prefix log message prefix
fname filename

Definition at line 252 of file log.c.

References yaz_log_init_file(), yaz_log_init_level(), and yaz_log_init_prefix().

void yaz_log_init_file ( const char *  fname  ) 

sets log to a file

Parameters:
fname filename

Definition at line 141 of file log.c.

References use_file, use_none, use_stderr, yaz_log_close(), and yaz_log_reopen().

Referenced by check_options(), yaz_check_init_log(), and yaz_log_init().

void yaz_log_init_level ( int  level  ) 

sets log level

Parameters:
level (combination of YLOG_..)

Definition at line 201 of file log.c.

References mask, name, yaz_log(), yaz_log_reopen(), YLOG_FLUSH, YLOG_LAST_BIT, and YLOG_LOGLVL.

Referenced by check_options(), and yaz_log_init().

void yaz_log_init_max_size ( int  mx  ) 

sets limit in bytes for size for log file

Parameters:
mx size in bytes
Sets the max size for a log file. Zero means no limit. Negative means built-in limit (1GB)

Definition at line 261 of file log.c.

Referenced by check_options().

void yaz_log_init_prefix ( const char *  prefix  ) 

sets log message prefix

Parameters:
prefix log message prefix

Definition at line 236 of file log.c.

References yaz_snprintf().

Referenced by yaz_log_init().

void yaz_log_init_prefix2 ( const char *  prefix  ) 

sets second log message prefix

Parameters:
prefix log message prefix

Definition at line 244 of file log.c.

References yaz_snprintf().

int yaz_log_mask_str ( const char *  str  ) 

converts log level string to log level (integer)

Parameters:
str log level string
Returns:
log level mask
yaz_log_mask_str() converts a comma-separated list of log levels to a bit mask. Starts from default level, and adds bits as specified, unless 'none' is specified, which clears the list. If a name matches the name of a YLOG_BIT above, that one is set. Otherwise a new value is picked, and given to that name, to be found with yaz_log_module_level()

Definition at line 546 of file log.c.

References yaz_log_mask_str_x().

Referenced by check_options().

int yaz_log_mask_str_x ( const char *  str,
int  level 
)

converts log level string to log level with "start" level

Parameters:
str log level string
level initialing log level
Returns:
log level mask
yaz_log_mask_str_x() is like yaz_log_mask_str(), but with a given start value

Definition at line 552 of file log.c.

References mask.

Referenced by yaz_log_mask_str().

int yaz_log_module_level ( const char *  name  ) 

returns level for module

Parameters:
name module name
yaz_log_module_level() returns a log level mask corresponding to the module name. If that had been specified on the -v arguments (that is passed to yaz_log_mask_str()), then a non-zero mask is returned. If not, we get a zero. This can later be used in yaz_log for the level argument

Definition at line 526 of file log.c.

References mask, yaz_log(), and YLOG_LOGLVL.

Referenced by bend_init(), iochan_create(), nmem_create(), odr_createmem(), odr_reset(), xcalloc_f(), xmalloc_f(), xmalloc_trav_f(), xrealloc_f(), xstrdup_f(), and yaz_strerror().

void yaz_log_reopen ( void   ) 

Definition at line 354 of file log.c.

Referenced by yaz_log_init_file(), and yaz_log_init_level().

void yaz_log_set_handler ( void(*)(int, const char *, void *)  func,
void *  info 
)

sets custom log handler

Parameters:
func custom log handler
info custom pointer to be passed to func handler
Allows log output to be captured to something else.. The func parameter takes a log level, a message + custom pointer

Definition at line 269 of file log.c.

void yaz_log_time_format ( const char *  fmt  ) 

sets time format for log mesages

Parameters:
fmt format (strftime)
Sets the format of the timestamp. See man 3 strftime. Calling with "old" sets to the old format "11:55:06-02/11" Calling with NULL or "" sets to the new format "20041102-115719" If not called at all, the old format is used, for backward compatibility

Definition at line 469 of file log.c.

References TIMEFORMAT_LEN.

Referenced by check_options().

void yaz_log_trunc ( void   ) 

Truncate the log file.

Definition at line 359 of file log.c.

Referenced by yaz_check_init_log().

void yaz_log_xml_errors ( const char *  prefix,
int  log_level 
)

Makes Libxml2/Libxslt log errors via yaz_log.

Parameters:
prefix prefix to use for log messages (may be 0)
log_level log level to use for messages

Definition at line 42 of file xmlerror.c.

Referenced by check_options().


Generated on Wed Jun 18 11:17:01 2008 for YAZ by  doxygen 1.5.6