Functions to assist with debug logging.
- Source:
Methods
(inner) logger(loggerFunction) → {Client~observerCallback}
Function that can be the observer
for a Client.
Will call loggerFunction
with a string representation of each RequestResult.
An example logging string:
Fauna POST /
Request JSON: {
"data": ...
}
Response headers: {
"x-faunadb-host": ...,
"x-faunadb-build": ...,
"connection": "close",
"content-length": ...,
"content-type": "application/json;charset=utf-8"
}
Response JSON: {
"resource": {
"ref": { ... },
"class": { ... },
"ts": ...
}
}
Response (201): Network latency 13ms
Parameters:
Name | Type | Description |
---|---|---|
loggerFunction |
loggerCallback |
- Source:
Returns:
Example
var client = new Client({
... other options ...
observer: logger(console.log)
})
client.ping() // Logs the request and response.
(inner) showRequestResult(requestResult) → {string}
Convenience function used by logger to transform a RequestResult to a string for logging.
Parameters:
Name | Type | Description |
---|---|---|
requestResult |
RequestResult |
- Source:
Returns:
string to be logged.
- Type
- string
Type Definitions
loggerCallback(logged)
A user provided log line handler.
Parameters:
Name | Type | Description |
---|---|---|
logged |
string |
- Source: