Ejemplo n.º 1
0
static void print(zt_log_ty *log, zt_log_level level, char *fmt, va_list ap)
{
    char *nfmt = zt_log_gen_fmt( log, fmt, level, log->opts);

    vfprintf(stderr, nfmt, ap);
    XFREE(nfmt);
}
Ejemplo n.º 2
0
static void
print(zt_log_ty * log, zt_log_level level, const char * file, int line, const char * function, const char * fmt, va_list ap) {
    char       * nfmt         = NULL;
    int          syslog_level = 0;
    unsigned int level_flag   = 0;

    switch (level) {
        case zt_log_emerg:
            syslog_level = LOG_EMERG;
            break;
        case zt_log_alert:
            syslog_level = LOG_ALERT;
            break;
        case zt_log_crit:
            syslog_level = LOG_CRIT;
            break;
        case zt_log_err:
            syslog_level = LOG_ERR;
            break;
        case zt_log_warning:
            syslog_level = LOG_WARNING;
            break;
        case zt_log_notice:
            syslog_level = LOG_NOTICE;
            break;
        case zt_log_info:
            syslog_level = LOG_INFO;
            break;
        case zt_log_debug:
            syslog_level = LOG_DEBUG;
            break;
        default:
            syslog_level = LOG_ERR;
            break;
    } /* switch */

    /* honor level flag if it is set in the logger opts. for the rest of the
     * zt flags, defer to syslog settings */
    level_flag = (log->opts & ZT_LOG_WITH_LEVEL) ? ZT_LOG_WITH_LEVEL : 0;
    nfmt       = zt_log_gen_fmt(log, fmt, file, line, function, level, level_flag);
    vsyslog(syslog_level, nfmt, ap);

    zt_free(nfmt);
} /* print */