1.0.2 • Published 11 months ago

@stegripe/pino-logger v1.0.2

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
11 months ago

@stegripe/pino-logger

Plugin for [@sapphire/framework](https://github.com/sapphire/framework) used to handle logging with Pino.

GitHub

Description

This plugin is used to create custom loggers with Pino.

Features

  • Easy to use

Installation

@stegripe/pino-logger depends on the following packages. Be sure to install these along with this package!

You can use the following command to install this package, or replace pnpm install with your package manager of choice.

pnpm install @stegripe/pino-logger

Usage

import { SapphireClient, SapphireClientOptions } from "@sapphire/framework";
import { PinoLogger } from "@stegripe/pino-logger";

export class MyClient extends SapphireClient {
    public constructor(clientOptions: SapphireClientOptions) {
        super({
            ...clientOptions,
            logger: {
                instance: new PinoLogger({
                    name: "MyClient",
                    timestamp: true,
                    level: ISDEV ? "debug" : "info",
                    formatters: {
                        bindings: () => ({ pid: `MyClient@${process.pid}` })
                    }
                })
            }
        });
    }
}

With Custom Formatters

import { SapphireClient, SapphireClientOptions } from "@sapphire/framework";
import { PinoLogger } from "@stegripe/pino-logger";

export class MyClient extends SapphireClient {
    public constructor(clientOptions: SapphireClientOptions) {
        super({
            ...clientOptions,
            logger: {
                instance: new PinoLogger({
                    name: "MyClient",
                    timestamp: true,
                    level: ISDEV ? "debug" : "info",
                    formatters: {
                        bindings: () => ({ pid: `MyClient@${process.pid}` })
                    },
                    transport: {
                        targets: [{
                            target: "pino-pretty",
                            level: ISDEV ? "debug" : "info",
                            options: { translateTime: "SYS:yyyy-mm-dd HH:MM:ss" }
                        }]
                    }
                })
            }
        });
    }
}
1.0.2

11 months ago

1.0.1

12 months ago

1.0.0

12 months ago