Replacing Logger
Is there any way to replace the logger with custom on or editing it's style at least
Solution:Jump to solution
we have @sapphire/plugin-logger, or if that style doesnt suite you then you'll have to make a similar plugin yourself.
27 Replies
Solution
we have @sapphire/plugin-logger, or if that style doesnt suite you then you'll have to make a similar plugin yourself.
@sapphire/plugin-logger
Plugin for @sapphire/framework to have pretty console output
❯ Author: sapphiredev
❯ Maintainers: favna, kyranet, and vladfrangu
❯ Latest version: 3.0.6
❯ License: MIT
❯ Date Created: <t:1608819495:d>
❯ Date Modified: <t:1697502716:d>
Dependencies:
@sapphire/timestamp and colorette
Will that replace the messages of loading commands listeners ... ?
Note to self: add screenshot of how it looks to the readme
Yes, all logs from sapphire and all logs that were logged through container.logger.<level>
Ok but If I made custom one how to integrate it
I hope so 😀
People before notion:
@Favna Now I created custom logger
and replaced it with the logger of the container
but the mesages while running bot not like my own so how to replace it too
huh
idgi
You said I must make custom logger if the style doesn't suite my needs
I did like you said
but the used logger here isn't like my custom logger
did you actually register it
How to register it?
also I see a bunch of
console.log
only, no styles or anything
I said "like the plugin" so look at the plugin's code 👀That's a temp form
Shit the source is too large
Is there any easier way?
wdym too large. It's just like 3 files or something lol
Can I implement it or something like this?
Is there any way to register my customLogger that extends ILogger
I just told you how
How? 👀
look at the plugin's code, it has the answer
im not here to spoon feed you code
?
that's part of it yes
Should I copy all of this?
you can follow a different structure and you can merge some files if you want but yes
and you dont need the register if you just inline it to your client
you'll see how the plugin modifies the client options, you can just inline that
Ok but where to type this line
SapphireClient.plugins.registerPreGenericsInitializationHook(LoggerPlugin[preGenericsInitialization], 'Logger-PreGenericsInitialization');
before client instance of afterbefore
just like how plugins are called before
FWIW the reason I (and anyone else ) wont spoonfeed all the answers and code is because at that point we may as well be writing your bot for you (which would cost you anyway). We expect at least some proactiveness and self incentive from developers. Questions like the ones you've been asking you could've found the answers to very easily by just trying and if it doesn't work try something else and again and again, that's a far far far better way to learn than gettting all the answers on a silver plater.
First off, thanks for your help and patience. I'm new to this framework, and despite extensive research, I'm struggling to find the answers I need. I'm genuinely committed to gaining more experience with this framework through docs, but sometimes my inquiries are kept without clear answers. Seeking guidance from experienced individuals is much better.
I feel your pain. I spend hours trying to replace the default Logger provided by the plugin using the
ClientOptions
:
Until I realized that is not possible because the plugin always create a new instance ignoring what we pass on ClientOptions
:
I opened an issues and will send a PR for it: https://github.com/sapphiredev/plugins/issues/496Also said on the GH issue but if you want to use your own instance just dont use the plugin...
Issue closed as "wont fix"