Branch: Tag:

2015-10-15

2015-10-15 11:53:33 by Marcus Agehall <agehall@roxen.com>

Added basic request and configuration JS logging.

874:    hp = 0;    TIMER_END(parse_got);    +  do { +  mapping tmp = ([ +  "event" : "BEGIN_REQUEST", +  "tid" : sprintf("0x%X", this_thread()->id_number()), +  "remote" : remoteaddr, +  ]); +  +  // Indicate parent request if one exists +  if (objectp(root_id) && (root_id != root_id->root_id)) { +  tmp->subrequest = Val.True; // We should get rid of this one +  tmp->prid = root_id->request_uuid; +  werror("Subrequest detected!\n"); +  } +  req_js_logger->log(tmp); +  } while(0); +  +     // The following was earlier a separate function parse_got_2.       TIMER_START(parse_got_2);
968:    }    }    +  req_js_logger->log(([ +  "event" : "GOT_HEADERS", +  "headers" : request_headers, +  "prot" : prot, +  "data_length" : strlen(data), +  ])); +     TIMER_START(parse_got_2_parse_headers);    foreach (request_headers; string linename; array|string contents)    {
1872:    }       conf->log(file, this_object()); +  +  req_js_logger->log(([ +  "event" : "LOG_REQUEST", +  "htime" : handle_time, +  "qtime" : queue_time, +  "rtime" : gethrtime()-hrtime, +  ]));    }    }    if( !port_obj )
2519:   {    TIMER_START(send_result);    +  req_js_logger->log(([ +  "event" : "SEND_RESULT_BEGIN", +  ])); +     if (my_fd)    CHECK_FD_SAFE_USE;   
2577:    {    if((file->file == -1) || file->leave_me)    { +  req_js_logger->log(([ +  "event" : "SEND_RESULT_END", +  "msg" : "No result", +  ]));    TIMER_END(send_result);    file = 0;    pipe = 0;
3014:       REQUEST_WERR("HTTP: handle_request()");    TIMER_START(handle_request); +  req_js_logger->log(([ +  "event" : "HANDLE_REQUEST_BEGIN", +  "qtime" : queue_time, +  ])); + #ifdef TIMERS + #define LOG_HANDLE_END() do { req_js_logger->log((["event" : "HANDLE_REQUEST_END", "handle_time" : timers->handle_request ])); } while(0) + #else + #define LOG_HANDLE_END() + #endif    -  +    #ifdef MAGIC_ERROR    if(prestate->old_error)    {
3028: Inside #if defined(MAGIC_ERROR)
   "data":generate_bugreport( @err ),    ]);    TIMER_END(handle_request); +  LOG_HANDLE_END()    send_result();    return;    } else {
3041: Inside #if defined(MAGIC_ERROR)
   "data":handle_error_file_request( @err ),    ]);    TIMER_END(handle_request); +  LOG_HANDLE_END();    send_result();    return;    }
3076:    if (result && result->pipe) {    REQUEST_WERR("HTTP: handle_request: pipe in progress.");    TIMER_END(handle_request); +  req_js_logger->log(([ +  "event" : "PIPE_BEGIN", +  ])); +  LOG_HANDLE_END();    return;    }    file = result;
3093:       TIMER_END(handle_request);    send_result(); -  +  LOG_HANDLE_END();    }) {    call_out (disconnect, 0);    report_error("Internal server error: " + describe_backtrace(err));
3284:       TIMER_END(find_conf);    +  req_js_logger->log(([ +  "event" : "GOT_REQUEST", +  "data_length" : strlen(data), +  "path" : path, +  "raw_url" : raw_url, +  ])); +     // The "http_request_init" provider hook allows modules to do    // things very early in the request path, before the request is    // put in the handler queue and before the protocol cache is
3644:    REQUEST_WERR("HTTP: Calling roxen.handle().");    queue_time = gethrtime();    queue_length = roxen.handle_queue_length(); +  req_js_logger->log(([ +  "event" : "ENTER_QUEUE", +  "qlen" : queue_length, +  "vars" : real_variables, +  "cookies" : cookies, +  ]));    roxen.handle(handle_request_from_queue);    })    {
3751:   void chain(object f, object c, string le)   {    my_fd = f; -  +    #if defined(DEBUG) && defined(THREADS)    if (this_thread() != roxen->backend_thread)    error ("Not called from backend\n");