@stegripe/pino-logger
v1.0.2
Published
A simple logger for Sapphire Framework using Pino.
Downloads
47
Readme
@stegripe/pino-logger
Plugin for @sapphire/framework
used to handle logging with Pino.
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" }
}]
}
})
}
});
}
}