ShirayukiHaruka - **[Sapphire Logging]**Hello! I'...

[Sapphire Logging] Hello! I've been using Sapphire for a while now, and wondering if there is a way to use custom logger instead sapphire's default one. Context: I've configured winston as my logger and to make my log consistent, I'd like to use my logger instance to log sapphire's one. I've read the source code and kinda have some speculation. - SapphireClient uses ClientLoggerOptions to define the logger field when constructing the client. - ClientLoggerOptions contains level and instance fields, where instance implements ILogger interface. By this, my idea is to create a custom logger class that implements the said interface, then probably make it as singleton so it uses the same logger instance every time. My question is, is this the preferred way or there is a better approach for this? Thanks!
S
Sawako532d ago
as you say is the best way Create the class that implements the Sapphire Logger interface and in the methods use winston
F
Favna532d ago
Should also note that if you run your bot in pm2 or docker in production and your only use for Winston is to log to a file that those services already log to files and you're double logging by using Winston. But yes custom loggers always have to extend the built in logger class otherwise they won't log internal messages
F
Favna532d ago
Also if you're a real gigachad you make it an npm package and PR it to https://github.com/sapphiredev/awesome-sapphire because you're far from the first person who wants a Winston based logger
GitHub
GitHub - sapphiredev/awesome-sapphire: Manually curated collection ...
Manually curated collection of resources, plugins, utilities, and other assortments for the Sapphire Community projects. - GitHub - sapphiredev/awesome-sapphire: Manually curated collection of reso...
白雪はるか532d ago
Nice, thanks! I'll proceed with my current way. By the way, is there any convention I should follow if I were to write the plugin? I saw this repo https://github.com/sapphiredev/sapphire-template and wondering if I should use this template or it's up to repo owner on how to structure,document,and write the code.
GitHub
GitHub - sapphiredev/sapphire-template: Template to be used for Sap...
Template to be used for Sapphire Project repositories - GitHub - sapphiredev/sapphire-template: Template to be used for Sapphire Project repositories
F
Favna532d ago
other than the /register convention that is used for other plugins (see https://github.com/sapphiredev/plugins ) not really
GitHub
GitHub - sapphiredev/plugins: Plugins for the Sapphire Framework
Plugins for the Sapphire Framework. Contribute to sapphiredev/plugins development by creating an account on GitHub.
Want results from more Discord servers?
Add your server
More Posts
Ben855 - I can't seem to get slash subcommands wor...I can't seem to get slash subcommands working. I'm able to register them just fine but my chatInputRStealth - Any idea what's going on here?Any idea what's going on here?RVX - new to coding here. (very new) how do i un...new to coding here. (very new) how do i unregister a command? looks like registering a command an! 𝑱𝒂𝒎𝒆𝒔__ - Hello, I need help with my backup cod...Hello, I need help with my backup code. The rooms are created correctly but the categories are creatBigBrainAFK - So how does one interact with Forum ...So how does one interact with Forum channels in sapphireSlinky - Hello, I just started using the framework...Hello, I just started using the framework yesterday and currently having a issue trying to reset theHyperfire - How would i ago about adding custom fi...How would i ago about adding custom fields to commands? Like for example aliasespochiko - Hello! does anyone kno whow to fix this ...Hello! does anyone kno whow to fix this problem? ive been trying to figure out why for the past 30 mNitsua - Editing a previously ran slash command re...Editing a previously ran slash command results in an error. ``` Encountered error on chat input comwilluhmjs - ```jsValidationError s.string Exp...```js ValidationError > s.string Expected a string primitive Received: | undefined at Stsam - ```srcconfig.ts737 - error TS2345 Argum...``` src/config.ts:7:37 - error TS2345: Argument of type 'string' is not assignable to parameter of tRhys - ^Sort of related to above, does inheritance...^Sort of related to above, does inheritance work with commands? I've got a few commands for openinThatGuyJamal - Is it possible to make a default va...Is it possible to make a default value for registering command meta data. Like: ``` guildIds: isCanaUser - ```javascriptconst { Client, Events, Gate...```javascript const { Client, Events, GatewayIntentBits } = require('discord.js'); const client Ben855 - For autocomplete arguments in slash comma...For autocomplete arguments in slash commands, if the user enters something that wasn't available in Rhys - Is there a way to use preconditions to remo...Is there a way to use preconditions to remove redundant if checks? For example: ```typescript @AppTobyy - how do i fixhow do i fixTobyy -