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

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

本文简介:选择自 liangbowen 的 blog

    char time_str[apr_ctime_len];

    apr_ctime(time_str, apr_time_now());
    ap_log_error(aplog_mark, aplog_crit, 0, null,
                 "[%s] file %s, line %d, assertion \"%s\" failed",
                 time_str, szfile, nline, szexp);
#if defined(win32)
    debugbreak();
#else
    /* unix assert does an abort leading to a core dump */
    abort();
#endif
}

/* piped log support */

#ifdef ap_have_reliable_piped_logs
/* forward declaration */
static void piped_log_maintenance(int reason, void *data, apr_wait_t status);

static int piped_log_spawn(piped_log *pl)
{
    int rc = 0;
    apr_procattr_t *procattr;
    apr_proc_t *procnew = null;
    apr_status_t status;

    if (((status = apr_procattr_create(&procattr, pl->p)) != apr_success) ||
        ((status = apr_procattr_child_in_set(procattr,
                                             ap_piped_log_read_fd(pl),
                                             ap_piped_log_write_fd(pl)))
        != apr_success) ||
        ((status = apr_procattr_child_errfn_set(procattr, log_child_errfn))
         != apr_success) ||
        ((status = apr_procattr_error_check_set(procattr, 1)) != apr_success)) {
        char buf[120];
        /* something bad happened, give up and go away. */
        ap_log_error(aplog_mark, aplog_startup, 0, null,
                     "piped_log_spawn: unable to setup child process '%s': %s",
                     pl->program, apr_strerror(status, buf, sizeof(buf)));
        rc = -1;
    }
    else {
        char **args;
        const char *pname;

        apr_tokenize_to_argv(pl->program, &args, pl->p);
        pname = apr_pstrdup(pl->p, args[0]);
        procnew = apr_pcalloc(pl->p, sizeof(apr_proc_t));
        status = apr_proc_create(procnew, pname, (const char * const *) args,
                                 null, procattr, pl->p);

        if (status == apr_success) {
            pl->pid = procnew;
            ap_piped_log_write_fd(pl) = procnew->in;
            apr_proc_other_child_register(procnew, piped_log_maintenance, pl,
                                          ap_piped_log_write_fd(pl), pl->p);
        }
        else {
            char buf[120];
            /* something bad happened, give up and go away. */
            ap_log_error(aplog_mark, aplog_startup, 0, null,

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

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

go top