Better logging

This commit is contained in:
Marcin Czop 2024-11-19 18:15:53 +01:00
parent fa77a856ca
commit 4f8ed10e34
No known key found for this signature in database
GPG key ID: 44BCC84471234D0D
2 changed files with 6 additions and 4 deletions

View file

@ -28,10 +28,10 @@ class Bot extends Client {
}
public async start(): Promise<void> {
this.log.debug("Logging in with token...");
this.log.info("Logging in with token...");
this.login(process.env.TOKEN);
this.log.debug("Loading commands and events...");
this.log.info("Loading commands...");
const commandFiles: string[] = await glob(`${__dirname}/commands/**/*.ts`);
commandFiles.map(async (fileName: string) => {
const filePath = path.resolve(fileName);
@ -40,6 +40,7 @@ class Bot extends Client {
if (file.aliases) file.aliases.map((alias) => this.commands.set(alias, file));
});
this.log.info("Loading events...");
const eventFiles: string[] = await glob(`${__dirname}/events/**/*.ts`);
eventFiles.map(async (fileName: string) => {
const filePath = path.resolve(fileName);
@ -48,7 +49,7 @@ class Bot extends Client {
this.on(file.event, file.run.bind(this, this));
});
this.log.debug("Initialization complete!");
this.log.info("Initialization complete!");
}
public getUserFromMention(mention: string): User | undefined {

View file

@ -5,6 +5,7 @@ let transport;
if (process.env.NODE_ENV === "production") {
transport = pino.transport({
target: "pino-loki",
level: process.env.LOG_LEVEL || "info",
options: {
batching: true,
interval: 5,
@ -21,9 +22,9 @@ if (process.env.NODE_ENV === "production") {
} else {
transport = pino.transport({
target: "pino-pretty",
level: process.env.LOG_LEVEL || "info",
options: {
colorize: true,
minimumLevel: "debug",
},
});
}