log.cc File Reference

functions used to generate log messages, and logging of debug messages More...

#include "jabberd.h"

Namespaces

namespace  xmppd

Functions

void debug_log (char const *zone, char const *msgfmt,...)
void debug_log2 (char const *zone, int type, char const *msgfmt,...)
void logger (char const *type, char const *host, char const *message)
void log_notice (char const *host, char const *msgfmt,...)
void log_warn (char const *host, char const *msgfmt,...)
void log_alert (char const *host, char const *msgfmt,...)
void log_generic (char const *logtype, char const *id, char const *type, char const *action, char const *msgfmt,...)
void log_record (char const *id, char const *type, char const *action, char const *msgfmt,...)
int get_debug_flag ()
void set_debug_flag (int v)
void set_cmdline_debug_flag (int v)
void set_debug_facility (int facility)
int log_get_level (char const *level)
int log_get_facility (char const *facility)

Variables

int _debug_facility = -1
int debug_flag = 0
int cmdline_debug_flag = 0
xht debug__zones

Detailed Description

functions used to generate log messages, and logging of debug messages

Generated log messages are routed to a logging component using the XML router. Generated debug log messages are not routed but either displayed to the standard error output or sent to the syslog (Depending on the jabberd configuration).


Function Documentation

void debug_log ( char const *  zone,
char const *  msgfmt,
  ... 
)

Generate a debug log message

This generates a debugging message. The function should not be called directly. Instead the macro log_debug should be called, which first checks if debugging is enabled.

Do not use this function or log_debug at all. Better use log_debug2.

Parameters:
zone the zone (file) the function is called from. __ZONE__ should be used here.
msgfmt the format string for the log message, parameters like for printf() are given afterwards

References _debug_facility, and MAX_LOG_SIZE.

void debug_log2 ( char const *  zone,
int  type,
char const *  msgfmt,
  ... 
)

Generate a debug log message

This generates a debugging message. The function should not be called directly. Instead the macro log_debug2 should be called, which first checks if debugging is enabled.

Parameters:
zone the zone (file) the function is called from. __ZONE__ should be used here.
type LOGT_* constent telling which type of debug log message is passed
msgfmt the format string for the log message, parameters like for printf() are given afterwards

References _debug_facility, get_debug_flag(), and MAX_LOG_SIZE.

int get_debug_flag ( void   )  [inline]

get the current debugging mask

References debug_flag.

Referenced by debug_log2().

void log_alert ( char const *  host,
char const *  msgfmt,
  ... 
)

generate a log message of type "alert"

Parameters:
host the sending host (domain) of the log message - NULL if the host is not known, in that case the message is logged as jabberd internal
msgfmt the format string for the message, parameters are passed afterwards like for the printf() function

References logger().

Referenced by dialback_out_read(), main(), and mio_listen().

void log_generic ( char const *  logtype,
char const *  id,
char const *  type,
char const *  action,
char const *  msgfmt,
  ... 
)

writing log messages of arbitrary logging type

Parameters:
logtype logging type (e.g. "record")
id to which id is the message related
type type of the log message (e.g. "session")
action action that is logged (e.g. a failed auth)
msgfmt printf()-like format string, parameters are following

References deliver(), dpacket_new(), j_strlen(), log_debug2, LOGT_DELIVER, NS_SERVER, xmlnode_insert_cdata(), xmlnode_new_tag_ns(), xmlnode_put_attrib_ns(), xmlnode_serialize_string(), and ZONE.

Referenced by log_record().

int log_get_facility ( char const *  facility  ) 

get the facility value for a syslog facility

Parameters:
facility as a string
Returns:
numerical facility value or -1 on error

References j_strcmp().

int log_get_level ( char const *  level  ) 

get the level value for a syslog level

Parameters:
level as a string
Returns:
numerical level value or -1 on error

References j_strcmp().

void log_notice ( char const *  host,
char const *  msgfmt,
  ... 
)

generate a log message of type "notice"

Parameters:
host the sending host (domain) of the log message - NULL if the host is not known, in that case the message is logged as jabberd internal
msgfmt the format string for the message, parameters are passed afterwards like for the printf() function

References logger().

Referenced by _dnsrv_beat_packets(), _js_routed_error_packet(), _js_routed_packet(), _mio_ssl_read(), _mio_ssl_write(), _mio_xml_parser(), _xdb_convert_hostspool(), deliver(), deliver_fail(), dialback_check_settings(), dialback_in_read_db(), dialback_out_connection_cleanup(), dialback_out_read(), dnsrv_deliver(), js_users_gc(), jsm_deserialize(), main(), mio_ssl_starttls(), mio_ssl_verify(), mod_dynamic(), unregister_instance(), and xdb_file_phandler().

void log_record ( char const *  id,
char const *  type,
char const *  action,
char const *  msgfmt,
  ... 
)

generic log record support

Parameters:
id to which id is the message related
type the type of the log message (e.g. "session")
action action that is logged (e.g. a failed auth)
msgfmt printf()-like format string, parameters are following

References log_generic().

Referenced by _dialback_miod_hash_cleanup().

void log_warn ( char const *  host,
char const *  msgfmt,
  ... 
)

generate a log message of type "warn"

Parameters:
host the sending host (domain) of the log message - NULL if the host is not known, in that case the message is logged as jabberd internal
msgfmt the format string for the message, parameters are passed afterwards like for the printf() function

References logger().

Referenced by _js_routed_session_control_packet(), _js_routed_session_packet(), _mio_xml_parser(), deliver_fail(), dialback_check_settings(), dialback_in_read_db(), dialback_in_verify(), dialback_miod_read(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), dpacket_new(), js_deliver(), js_packet(), mio_init(), mio_ssl_init(), mod_auth_crypt(), pthsock_client(), set_debug_facility(), xdb_file_load(), and xdb_file_phandler().

void logger ( char const *  type,
char const *  host,
char const *  message 
)

send a log message to the logging components

Parameters:
type the type of log message (one of "notice"+/"record", "warn"+, "alert", "stat"+, "info", "emerg", "crit", or "err"+ - in jabberd only the marked ones are used - "debug" should not be used as debugging messages should not be routed on the XML router)
host the sending host (domain) of the message, or NULL if no sending host is known (the message are than logged as jabberd internal)
message The message to be logged

References deliver(), dpacket_new(), j_strlen(), log_debug2, LOGT_DELIVER, NS_SERVER, xmlnode_insert_cdata(), xmlnode_new_tag_ns(), xmlnode_put_attrib_ns(), xmlnode_serialize_string(), and ZONE.

Referenced by log_alert(), log_notice(), and log_warn().

void set_cmdline_debug_flag ( int  v  ) 

set the value of the cmdline_debug_flag which is always ORed to the value that is set by set_debug_flag() this will reset the mask set with set_debug_flag(), so set_cmdline_debug_flag() should be called first.

Parameters:
v the debug mask given on the command line

References cmdline_debug_flag, and debug_flag.

Referenced by main().

void set_debug_facility ( int  facility  ) 

set the facility used to write debugging messages to syslog

Parameters:
facility the facility to use, -1 if writing to the standard output is requested

References _debug_facility, and log_warn().

void set_debug_flag ( int  v  ) 

set the debugging mask, if 0 no debugging is requested for other values debugging is enabled, the different bits in the value enable different log message types the value set with set_cmdline_debug_flag() (what the user specified on the command line) is always ORed to this value

Parameters:
v the new debugging mask

References cmdline_debug_flag, and debug_flag.


Variable Documentation

int _debug_facility = -1

facility to use for sending debugging messages to syslog - or -1 for not using syslog but stderr

Referenced by debug_log(), debug_log2(), and set_debug_facility().

the debug mask given at the command line - this is ORed with the mask given in the configuration file

Referenced by set_cmdline_debug_flag(), and set_debug_flag().

the debugging zones, that are enabled (key = zone string, value = zone string)

int debug_flag = 0

the active debugging mask (this is a bitmask of ORed LOGT_* constents)

Referenced by get_debug_flag(), set_cmdline_debug_flag(), and set_debug_flag().


Generated on Fri Mar 12 06:00:08 2010 for jabberd14 by  doxygen 1.6.1