new CLogger(options)
Custom base logger that inherits from winston.logger. Generic methods to log events like HTTP requests & responses live in this base class, but more component-specific methods should live in subclasses defined in individual component repos.
Custom Logger Method Guidelines
Custom logger methods for specific events should generally take at least one argument:
(event_obj, [custom_param_1], [custom_param_2])where event_obj is an object of some sort that represents the given event
(e.g. express Request or Response objects), and where custom params are defined on
an event-by-event basis, but generally inform the logger method about additional metadata
around the event that cannot be accessed on the event object.
Because some logger transports may expect log objects with a rigidly-defined and typed key set (e.g. BigQuery), these custom methods MUST specify:
- the
typeof event being logged, using keytype - the key-value metadata schema for each event
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | winston logger options object |
- Source:
Methods
httpRequestMiddleware(request, response, next)
Express middleware function to log all incoming HTTP requests using this clogger.httpRequest method
NOTE: must declare use of cookie-parser and response-time middleware BEFORE declaring this method in order to log all metadata properly
Parameters:
| Name | Type | Description |
|---|---|---|
request |
express Request object |
|
response |
express Response object |
|
next |
next middleware func |
- Source:
httpResponse(response)
Generically logs HTTP response.
NOTE: Assumes response-time module installed, looks for x-response-time header.
Parameters:
| Name | Type | Description |
|---|---|---|
response |
express response instance |
- Source:
httpResponseMiddleware(request, response, next)
DEPRECATED
Shouldn't use this as it will capture response too early on before the request has been processed.
Express middleware function to log all outgoing HTTP responses using this clogger.httpResponse method
Parameters:
| Name | Type | Description |
|---|---|---|
request |
express Request object |
|
response |
express Response object |
|
next |
next middleware func |
- Source: