@livy/json-formatter
v1.0.4
Published
Serializes Livy log records as JSON
Downloads
27
Maintainers
Readme
@livy/json-formatter
This Livy formatter formats log records as one-line JSON objects.
Basic Example
const { FileHandler } = require('@livy/file-handler')
const { JsonFormatter } = require('@livy/json-formatter')
const handler = new FileHandler('logs.txt', {
formatter: new JsonFormatter()
})
Installation
Install it via npm:
npm install @livy/json-formatter
Options
An object of options can be passed to this formatter's constructor.
The following options are available:
include
Type: Partial<IncludedRecordProperties>
Default: {}
Description: Which log record properties to include in the output. The passed object is merged into the following default:
{
datetime: true,
channel: true,
level: true,
severity: true,
message: true,
context: true,
extra: true
}
batchMode
Type: JsonFormatter.BATCH_MODE_NEWLINES | JsonFormatter.BATCH_MODE_JSON
Default: JsonFormatter.BATCH_MODE_NEWLINES
Description: How to store batched logs. BATCH_MODE_NEWLINES
will just put out newline-delimited JSON objects, as if log records came in sequentially. BATCH_MODE_JSON
wraps batched records in an array and outputs that.
Public API
batchMode
How batched records are formatted. Initially set through the batchMode
option.
include
Which log record properties to include in the output. Initially set through the include
option.