Jabberd14-1.6.0/jabberd/log.c/log_debug2

Last-modified: 2007-04-14 (土) 22:27:53

このページを編集する際は,編集に関する方針に従ってください.

概要

* 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.

引数

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

実装

void debug_log2(char *zone, const int type, const char *msgfmt, ...) {
    va_list ap;
    char message[MAX_LOG_SIZE];
    int offset;
    char *pos;
- フラグが一致しなければ出力しない
    /* debug type filtering */
    if (!(get_debug_flag()&type))
	 return;
    /* special per-zone filtering */
    if (!_debug_log_zonefilter(zone))
	 return;
    /* only add timestamps if writing to standard output */
    if (_debug_facility == -1) {
	 snprintf(message, sizeof(message), "%s %s ", debug_log_timestamp(), zone);
	 for (pos = message; *pos != '\0'; pos++); /* empty statement */
	 offset = pos - message;
    } else {
	 pos = message;
	 offset = 0;
    }
    va_start(ap, msgfmt);
    vsnprintf(pos, sizeof(message) - offset, msgfmt, ap);
#ifdef HAVE_SYSLOG
    if (_debug_facility == -1) {
	 fprintf(stderr,"%s\n", message);
    } else {
	 syslog(LOG_DEBUG|_debug_facility, "%s", message);
    }
#else
    syslog(LOG_DEBUG|_debug_facility, "%s", message);
#endif

}

呼出元

#related: relatedプラグインは廃止されました。