good-scribe

A Good Reporter

Usage no npm install needed!

<script type="module">
  import goodScribe from 'https://cdn.skypack.dev/good-scribe';
</script>

README

Table of Contents

Good-Scribe

File logging module for good process monitoring. Good-Scribe is a stripped down version of good-file that, when writing to file, automatically removes the _object from a Joi validation failure within the Hapi request lifecycle.

Usage

good-scribe is a good-reporter implementation to write hapi server events to log files.

Good Scribe

new GoodScribe (options, events)

Creates a new GoodScribe object with the following arguments

  • options - specifications for the file that will be used. All file operations are done in "append" mode.
    • String - a string that indicates the log file to use. Opened in "append" mode.
  • events - an object of key value pairs.
    • key - one of the supported good events indicating the desired hapi event subscription
    • value - a single string or an array of strings to filter incoming events. "*" indicates no filtering. null and undefined are assumed to be "*"

GoodScribe Methods

good-scribe implements the good-reporter interface and has no additional public methods.

Example usage within Hapi Manifest

{
    "server": {
        "load": { "sampleInterval": 1000 }
    },
    "connections": [
        {
            "port": 8080,
            "routes": { "timeout": { "server": 30000 } },
            "load": { "maxHeapUsedBytes": 1073741824, "maxRssBytes": 2147483648, "maxEventLoopDelay": 5000 },
            "labels": ["api", "http"]
        },
        {
            "port": 8443,
            "routes": { "timeout": { "server": 30000 } },
            "load": { "maxHeapUsedBytes": 1073741824, "maxRssBytes": 2147483648, "maxEventLoopDelay": 5000 },
            "labels": ["api", "https"]
        }
    ],
    "plugins": {
        "good": {
            "opsInterval": 5000,
            "logRequestHeaders": true,
            "reporters": [
                { "reporter": "good-console", "args": [{ "request": "*", "response": "*", "ops": "*", "log": "*", "error": "*" }] },
                { "reporter": "good-scribe", "args": ["./logs/request.log", { "request": "*" }] },
                { "reporter": "good-scribe", "args": ["./logs/response.log", { "response": "*" }] },
                { "reporter": "good-scribe", "args": ["./logs/ops.log", { "ops": "*" }] },
                { "reporter": "good-scribe", "args": ["./logs/log.log", { "log": "*" }] },
                { "reporter": "good-scribe", "args": ["./logs/error.log", { "error": "*" }] }
            ]
        }
    }
}