Library for writing to and accessing a debug log. Each log entry has a date, some identifying information, a severity, and a message body.
Exceptions that cause requests to fail are automatically logged at severity level FATAL.
Limits: Currently only the most recent 1000-1500 messages are stored, and bodies may be up to 1k in length.
2
3
4
5
6
7
8
dlog.info("request from IP: ", request.clientAddr);
dlog.info("request path is: ", request.path);
if (somethingBad()) {
dlog.warn("something bad happened");
}
Writes a message of the given severity to the debug log. In addition to the severity and message text, the debug log also tracks: the time the message is logged; the ID of the request that generated the message; and the type (preview, published, or shell) of the request that generated the message.
| number | severity | The severity of the message. |
| * | message | The message to log. |
| * | etc | ... |
Logs a fatal message. "Fatal" is generally used to indicate that execution cannot continue.
| * | message | The message to log. |
| * | etc | ... |
Logs an error message. "Error" is generally used when something bad and unexpected has happened.
| * | message | The message to log. |
| * | etc | ... |
Logs a warning message. "Warn" is generally used when something unexpected happened - perhaps a harbinger of greater errors to come.
| * | message | The message to log. |
| * | etc | ... |
Logs an info message. "Info" is generally used to note that something interesting has happened.
| * | message | The message to log. |
| * | etc | ... |
Provides programmatic access to the debug log's messages (for making your own dashboard, perhaps?).
The returned objects have fields that correspond to all recorded information about the message, namely:
- date: the message's date, in milliseconds since the epoch (UNIX time), suitable for passing to the Date constructor.
- requestId: the ID of the request that logged this message.
- requestType: the type of the request that logged this message ("preview", "published", or "shell").
- severity: the severity of the message.
- message: the logged message text.
| object | params? | Optional object with the following six optional properties: |
| number | params.howOld? | How far back (in milliseconds) to access logged messages. Default: 1 hour. |
| string | params.idFilter? | Only show messages created with this request ID. Default: no rescriction. |
| boolean | params.preview? | true to show messages generated from preview requests. Default: true. |
| boolean | params.published? | true to show messages generated from requests to the published app. Default: true. |
| boolean | params.shell? | true to show messages generated by the shell. Default: false. |
| number | params.maxSeverity? | The least severe message severity to show (all messages with a severity level more or equally severe will be returned). Default: 4. |
| array | An array of objects describing the logged messages. |