Stegripe Logo

@stegripe/pino-logger

Plugin for @sapphire/framework used to handle logging with Pino.

GitHub npm version npm downloads

This plugin is used to create custom loggers with Pino.

  • Easy to use

@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
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}` })
}
})
}
});
}
}
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" }
}]
}
})
}
});
}
}

Index

Classes