Module: clientLogger

Functions to assist with debug logging.

Methods


<inner> logger(loggerFunction)

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
Returns:
Type
Client~observerCallback
Example
var client = new Client({
  ... other options ...
  observer: logger(console.log)
})
client.ping() // Logs the request and response.

<inner> showRequestResult(requestResult)

Convenience function used by logger to transform a RequestResult to a string for logging.

Parameters:
Name Type Description
requestResult RequestResult
Returns:

string to be logged.

Type
string

Type Definitions


loggerCallback(logged)

A user provided log line handler.

Parameters:
Name Type Description
logged string