GLOBAL INDEX  |  FRAMES  |  NO FRAMES
Library: dlog
Overview

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.

source: dlog.js
examples
1
2
3
4
5
6
7
8
import("dlog");

dlog.info("request from IP: ", request.clientAddr);
dlog.info("request path is: ", request.path);

if (somethingBad()) {
  dlog.warn("something bad happened");
}
Functions
dlog.log(severity, message, etc)

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.

parameters
number severity The severity of the message.
* message The message to log.
* etc ...
dlog.fatal(message, etc)

Logs a fatal message. "Fatal" is generally used to indicate that execution cannot continue.

parameters
* message The message to log.
* etc ...
dlog.error(message, etc)

Logs an error message. "Error" is generally used when something bad and unexpected has happened.

parameters
* message The message to log.
* etc ...
dlog.warn(message, etc)

Logs a warning message. "Warn" is generally used when something unexpected happened - perhaps a harbinger of greater errors to come.

parameters
* message The message to log.
* etc ...
dlog.info(message, etc)

Logs an info message. "Info" is generally used to note that something interesting has happened.

parameters
* message The message to log.
* etc ...
dlog.messages(params)

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.
parameters
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.
returns
array An array of objects describing the logged messages.
dlog.clear()

Clears the debug log.

Objects
number
dlog.FATAL
Severity level FATAL.
number
dlog.ERROR
Severity level ERROR.
number
dlog.WARN
Severity level WARN.
number
dlog.INFO
Severity level INFO.
Generated by JsDoc Toolkit 1.3.3 [with AppJet Modifications] on Tue, 19 Aug 2008 01:36:25 GMT.