Branch: Tag:

2015-10-15

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

Added basic request and configuration JS logging.

326:    mapping(string:int(1..1)) enabled_modules = ([]);    mapping(string:array(int)) error_log=([]);    +  // The Configration logger class - allows overrides of the SocketLogger if needed. +  class ConfigurationLogger { +  inherit Logger.SocketLogger; +  } +  +  // Logger instance for this configuration. +  object cfg_js_logger; +    #ifdef PROFILE    mapping(string:array(int)) profile_map = ([]);   #endif
1211:    _request_uuid = (string)v;    };    +  // Logger class for requests. Intended to have a parent logger in +  // the parent request or its configuration. +  class RequestLogger { +  inherit Logger.BaseLogger; +  +  void log(mapping|string data) { +  // We find our parent logger by checking misc mapping, root +  // request and finally configuration object. +  // +  // NOTE: We do not fall back to the global main_logger here as a +  // design choice. +  parent_logger = parent_logger || +  (misc->orig && misc->orig->req_js_logger) || +  (objectp(root_id) && root_id->req_js_logger != this && root_id->req_js_logger) || +  (conf && conf->cfg_js_logger); +  +  if (!parent_logger) { +  return; // Nowhere to log... +  } +  +  ::log(data); +  } +  +  mapping merge_defaults(mapping msg) { +  // We always want the hrtime from the request as well as the thread id. +  msg = msg + ([ +  "time" : predef::time(), +  // We want the current hrtime, not the start of the request... +  "hrtime" : gethrtime(), +  ]); +  +  msg->rid = request_uuid; +  +  return ::merge_defaults(msg); +  } +  } +     Configuration conf; -  +  object req_js_logger = RequestLogger();       Protocol port_obj;    //! The port object this request came from.
1575:    return fmt == 'O' && sprintf("CookieJar(%O)" + OBJ_COUNT,    RequestID::this && real_cookies);    } +  +  string encode_json(int flags) { +  return Standards.JSON.encode(real_cookies);    } -  +  }       CookieJar|mapping(string:string) cookies;    //! The indices and values map to the names and values of the cookies sent