libu8
u8logging.h File Reference

These functions provide various ways of logging program events. More...

Functions

U8_EXPORT int u8_logger (int priority, u8_condition c, u8_string message)
 Possibly generates a log message for an (optional) condition. More...
 
U8_EXPORT int u8_log (int priority, u8_condition c, u8_string format_string,...)
 Possibly formats a log message for an (optional) condition. More...
 
U8_EXPORT u8_logfn u8_set_logfn (u8_logfn logfn)
 Sets the function used for log messages. More...
 
U8_EXPORT void u8_set_logixes (u8_string prefix, u8_string suffix)
 Sets the prefix and suffix string for non-syslog log messages. More...
 
U8_EXPORT void u8_set_logindent (u8_string indent)
 Sets the indentation string for log messages. More...
 
U8_EXPORT u8_string u8_message_prefix (u8_byte *buf, int buflen)
 Generates a message prefix into the given buffer, with output including process information controlled by the various u8_log_show variables. More...
 
U8_EXPORT void u8_syslog (int priority, u8_string format_string,...)
 Formats and outputs a string using syslog and the given priority level. More...
 
U8_EXPORT void u8_use_syslog (int flag)
 Control whether syslog is used together with stdio output. More...
 

Detailed Description

These functions provide various ways of logging program events.

Function Documentation

U8_EXPORT int u8_log ( int  priority,
u8_condition  c,
u8_string  format_string,
  ... 
)

Possibly formats a log message for an (optional) condition.

Whether and where this produces output depends on how the program is linked and configured.

Parameters
priorityan (int [-1,7]) priority level
ca string describing the condition (possibly NULL)
format_stringa utf-8 printf-like format string
...arguments for the format string
Returns
1 if the call actually produced output somewhere

References u8_do_printf(), and U8_STREAM_OWNS_BUF.

Referenced by u8_add_server(), u8_close_connpool(), u8_define_encoding(), u8_extalloc(), u8_file_existsp(), u8_file_readablep(), u8_file_writablep(), u8_get_connection(), u8_identify_session(), u8_init_server(), u8_iso8601_to_xtime(), u8_pop_exception(), u8_raise(), u8_random_vector(), u8_randomize(), u8_reconnect(), u8_renew_all(), u8_server_init(), u8_sessionid(), u8_shutdown_server(), u8_threadid(), and u8_use_syslog().

U8_EXPORT int u8_logger ( int  priority,
u8_condition  c,
u8_string  message 
)

Possibly generates a log message for an (optional) condition.

Whether and where this produces output depends on how the program is linked and configured.

Parameters
priorityan (int [-1,7]) priority level
ca string describing the condition (possibly NULL)
messagethe content of the message to be emmited
Returns
1 if the call actually produced output somewhere

Referenced by u8_clear_errors().

U8_EXPORT u8_string u8_message_prefix ( u8_byte *  buf,
int  buflen 
)

Generates a message prefix into the given buffer, with output including process information controlled by the various u8_log_show variables.

If buflen doesn't allow all the information to be shown, some information may be removed.

Parameters
bufa byte buffer in which to compose the prefix
buflenthe number of bytes in the buffer
Returns
a pointer to the buffer it was given, filled with context information and null terminated.

References u8_appid(), u8_elapsed_time(), u8_initialize_logging(), and u8_procinfo().

Referenced by u8_set_logindent().

U8_EXPORT u8_logfn u8_set_logfn ( u8_logfn  logfn)

Sets the function used for log messages.

Parameters
logfn
Returns
the previous logfn

References u8_do_printf(), and U8_STREAM_OWNS_BUF.

Referenced by u8_initialize_u8stdio().

U8_EXPORT void u8_set_logindent ( u8_string  indent)

Sets the indentation string for log messages.

Parameters
indenta string to be used as the indentation for log messages
Returns
void

References u8_indent_text(), and u8_message_prefix().

U8_EXPORT void u8_set_logixes ( u8_string  prefix,
u8_string  suffix 
)

Sets the prefix and suffix string for non-syslog log messages.

Parameters
prefix
suffix
Returns
void
U8_EXPORT void u8_syslog ( int  priority,
u8_string  format_string,
  ... 
)

Formats and outputs a string using syslog and the given priority level.

This does its output if u8_loglevel is greater than 0.

Parameters
priorityan (int) priority level passed to syslog
format_stringa utf-8 printf-like format string
...arguments for the format string
Returns
void

References u8_do_printf(), and U8_INIT_STATIC_OUTPUT.

Referenced by u8_use_syslog().

U8_EXPORT void u8_use_syslog ( int  flag)

Control whether syslog is used together with stdio output.

If flag is 1, syslog is used for notifications and warnings, together with the stderr.

Parameters
flagint

References u8_do_printf(), u8_graberr(), U8_INIT_STATIC_OUTPUT, u8_log(), and u8_syslog().