logger doesn't work properly

Hello, so I faced a logger problem. I registered the plugin in src/index.ts and plugin doesn't register properly, I think. Logs looks like a basic sapphire log without a plugin. How can I fix a problem with logger plugin?
No description
Solution:
"@sapphire/plugin-logger": "^3.0.7",
That's an old version. Please update to v4.0.2 on that note, these also....
Jump to solution
5 Replies
Favna
Favna3mo ago
Screenshot isn't loading on my shit data here abroad but I'll trust your text. Show code pls. Also make sure you recompile your TS code. Nuke dist, nuke tsconfig.tsbuildinfo if it exists, then rebuild. And please list your dependency versions
KaydaFox
KaydaFox3mo ago
nah discords CDN is down/having funky issues but as for their logs they just look like
[DEBUG] ApplicationCommandRegistry
[INFO] ApplicationCommandRegistries
[INFO] ApplicationCommandRegistries
[DEBUG] ApplicationCommandRegistry
[INFO] ApplicationCommandRegistries
[INFO] ApplicationCommandRegistries
with no colour
DemonWayne
DemonWayne3mo ago
src/index.ts:
import '@sapphire/plugin-logger/register';
import 'dotenv/config';
import AdvancedClient from '#lib/AdvancedClient';

const client = new AdvancedClient<true>();

client.login().catch(() => process.exit(0));
import '@sapphire/plugin-logger/register';
import 'dotenv/config';
import AdvancedClient from '#lib/AdvancedClient';

const client = new AdvancedClient<true>();

client.login().catch(() => process.exit(0));
src/lib/AdvancedClient.ts
import { ApplicationCommandRegistries, LogLevel, RegisterBehavior, SapphireClient } from '@sapphire/framework';
import { connect, set } from 'mongoose';
import { Partials } from 'discord.js';
import type { SapphireClientOptions } from '@sapphire/framework';

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);

export default class AdvancedClient<Ready extends boolean = boolean> extends SapphireClient<Ready> {
public constructor(options: SapphireClientOptions = {}) {
super({
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
sweepers: { messages: { interval: 120, lifetime: 60 } },
partials: [Partials.Message, Partials.Channel, Partials.GuildMember],

logger: { level: process.env.NODE_ENV === 'development' ? LogLevel.Debug : undefined },

...options,
});
}

public override login() {
this.connectDatabase();
return super.login();
}

private connectDatabase() {
set('strictQuery', true);
connect((process.env.DATABASE_URL ??= ''), {}).catch(err => {
if (err) throw err;
else this.logger.info('[Database] MongoDB successfully connected.');
});
}
}
import { ApplicationCommandRegistries, LogLevel, RegisterBehavior, SapphireClient } from '@sapphire/framework';
import { connect, set } from 'mongoose';
import { Partials } from 'discord.js';
import type { SapphireClientOptions } from '@sapphire/framework';

ApplicationCommandRegistries.setDefaultBehaviorWhenNotIdentical(RegisterBehavior.BulkOverwrite);

export default class AdvancedClient<Ready extends boolean = boolean> extends SapphireClient<Ready> {
public constructor(options: SapphireClientOptions = {}) {
super({
intents: ['Guilds', 'GuildMembers', 'GuildMessages', 'MessageContent'],
sweepers: { messages: { interval: 120, lifetime: 60 } },
partials: [Partials.Message, Partials.Channel, Partials.GuildMember],

logger: { level: process.env.NODE_ENV === 'development' ? LogLevel.Debug : undefined },

...options,
});
}

public override login() {
this.connectDatabase();
return super.login();
}

private connectDatabase() {
set('strictQuery', true);
connect((process.env.DATABASE_URL ??= ''), {}).catch(err => {
if (err) throw err;
else this.logger.info('[Database] MongoDB successfully connected.');
});
}
}
package.json
{
"dependencies": {
"@sapphire/async-queue": "^1.5.0",
"@sapphire/duration": "^1.1.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-logger": "^3.0.7",
"@sapphire/plugin-subcommands": "^6.0.3",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"mongoose": "^8.0.3"
},
"devDependencies": {
"@sapphire/decorators": "^6.0.2",
"@sapphire/eslint-config": "^5.0.2",
"@sapphire/ts-config": "^5.0.0",
"tsc-watch": "^6.0.4",
"typescript": "^5.1.6"
}
}
{
"dependencies": {
"@sapphire/async-queue": "^1.5.0",
"@sapphire/duration": "^1.1.2",
"@sapphire/framework": "^5.0.7",
"@sapphire/plugin-logger": "^3.0.7",
"@sapphire/plugin-subcommands": "^6.0.3",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"mongoose": "^8.0.3"
},
"devDependencies": {
"@sapphire/decorators": "^6.0.2",
"@sapphire/eslint-config": "^5.0.2",
"@sapphire/ts-config": "^5.0.0",
"tsc-watch": "^6.0.4",
"typescript": "^5.1.6"
}
}
Solution
Favna
Favna3mo ago
"@sapphire/plugin-logger": "^3.0.7",
That's an old version. Please update to v4.0.2 on that note, these also.
"@sapphire/async-queue": "^1.5.0", -> 1.5.2
"dotenv": "^16.3.1", -> 16.4.5
"mongoose": "^8.0.3" -> 8.2.1
"@sapphire/decorators": "^6.0.2", -> 6.0.4
"@sapphire/eslint-config": "^5.0.2" -> 5.0.4
"@sapphire/ts-config": "^5.0.0" -> 5.0.1
"@sapphire/async-queue": "^1.5.0", -> 1.5.2
"dotenv": "^16.3.1", -> 16.4.5
"mongoose": "^8.0.3" -> 8.2.1
"@sapphire/decorators": "^6.0.2", -> 6.0.4
"@sapphire/eslint-config": "^5.0.2" -> 5.0.4
"@sapphire/ts-config": "^5.0.0" -> 5.0.1
If you use Yarn as package manager you can use yarn upgrade-interactive (assuming yarn v4, if not you can use /tag query:yarnv4 in ##! /bot-commands to find out more about upgrading), if you use npm or pnpm then npx npm-upgrade followed by npm install / pnpm install, or regardless of package manager you can use the Version Lens vscode extension
DemonWayne
DemonWayne3mo ago
Thanks!