log.c -- 看文档,还不如看代码来的简单。[6]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 liangbowen 的 blog

    }

    if (logf && ((level & aplog_startup) != aplog_startup)) {
        errstr[0] = '[';
        ap_recent_ctime(errstr + 1, apr_time_now());
        errstr[1 + apr_ctime_len - 1] = ']';
        errstr[1 + apr_ctime_len    ] = ' ';
        len = 1 + apr_ctime_len + 1;
    } else {
        len = 0;
    }

    if ((level & aplog_startup) != aplog_startup) {
        len += apr_snprintf(errstr + len, max_string_len - len,
                            "[%s] ", priorities[level_and_mask].t_name);
    }

#ifndef tpf
    if (file && level_and_mask == aplog_debug) {
#if defined(_osd_posix) || defined(win32)
        char tmp[256];
        char *e = strrchr(file, '/');
#ifdef win32
        if (!e) {
            e = strrchr(file, '\\');
        }
#endif

        /* in osd/posix, the compiler returns for __file__
         * a string like: __file__="*posix(/usr/include/stdio.h)"
         * (it even returns an absolute path for sources in
         * the current directory). here we try to strip this
         * down to the basename.
         */
        if (e != null && e[1] != '\0') {
            apr_snprintf(tmp, sizeof(tmp), "%s", &e[1]);
            e = &tmp[strlen(tmp)-1];
            if (*e == ')') {
                *e = '\0';
            }
            file = tmp;
        }
#endif /*_osd_posix*/
        len += apr_snprintf(errstr + len, max_string_len - len,
                            "%s(%d): ", file, line);
    }
#endif /* tpf */

    if (r && r->connection) {
        /* xxx: todo: add a method of selecting whether logged client
         * addresses are in dotted quad or resolved form... dotted
         * quad is the most secure, which is why i'm implementing it
         * first. -djg
         */
        len += apr_snprintf(errstr + len, max_string_len - len,
                            "[client %s] ", r->connection->remote_ip);
    }
    if (status != 0) {
        if (status < apr_os_start_eaierr) {
            len += apr_snprintf(errstr + len, max_string_len - len,
                                "(%d)", status);
        }
        else if (status < apr_os_start_syserr) {
            len += apr_snprintf(errstr + len, max_string_len - len,
                                "(eai %d)", status - apr_os_start_eaierr);

本文关键:log.c -- 看文档,还不如看代码来的简单。
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top