/utils/logger 🪵
This module provides a logging utility for the XYZ API. The LOG process environment variable will be split into an array to determine which logs should be written out.
Possible log values are:
- req: Logs the req property from requests (see https://developer.mozilla.org/en-US/docs/Web/API/Request).
- req_url: Logs the url of the request.
- query_params: Logs query parameters sent to the query endpoint.
- query: Logs the sql to executed by calling the query endpoint.
- view-req-url: Logs the url of the requested view.
- cloudfront: Logs responses from requests made to cloudfront e.g. <staus_code> -
- mailer: Logs the response from email sending.
- mailer_body: Logs email from and two with the body.
- reqhost: Logs the host for the request.
- workspace: Logs responses for requests made to /workspace.
- Source
Requires
- module:/utils/processEnv
- module:crypto
Methods
(inner) log(log, keyopt)
Logs a message to the configured logger or console.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
log | string | | The message or object to log. | ||
key | string | <optional> | 'err' | The log level or key. |
- Source
(inner) logflare() → {function}
Configures the Logflare logger.
- Source
Returns:
A function that logs messages to Logflare.
- Type:
- function
(inner) postgresql() → {function}
Configures the PostgreSQL logger.
- Source
Returns:
A function that logs messages to a PostgreSQL database.
- Type:
- function