Comments (12)
I'm already happy there is not "wtf" logging level because that one was so stupid lmfao
from framework.
How about allowing users to inject their own logger that extends an abstract class, and having the default implementation use console.log?
from framework.
How about allowing users to inject their own logger that extends an abstract class, and having the default implementation use console.log?
That really would be the best option. Just a generic abstract class people can either implement or default. Reminds me a lot of most C# libraries tbh.
from framework.
Would like to see that, I support it.
from framework.
Sounds good, although the built-in logger will probably have opt-in logging, like all other libraries do.
const enum LogLevel {
Trace = 10,
Debug = 20,
Info = 30,
Warn = 40,
Error = 50,
Fatal = 60
}
interface ILogger {
trace(...values: readonly unknown[]): void;
debug(...values: readonly unknown[]): void;
info(...values: readonly unknown[]): void;
warn(...values: readonly unknown[]): void;
error(...values: readonly unknown[]): void;
fatal(...values: readonly unknown[]): void;
write(level: LogLevel, ...values: readonly unknown[]): void;
}
ILogger#write
serves so you can filter out emits (all other methods emit to it), i.e:
class Logger implements ILogger {
public minimum: LogLevel;
// Other methods
public write(level: LogLevel, ...values: readonly unknown[]): void {
if (level < this.minimum) return;
// Write to console
}
}
I think this streamlines with many other logger implementations, what are your thoughts? The idea behind LogLevel
taking steps of 10 each is so developers can augment it with new levels between existing ones, following TypeScript's requirement - we can augment enums as long as their values don't conflict.
I also took the names from StackOverflow and IBM.
Thoughts?
from framework.
Sounds good, although the built-in logger will probably have opt-in logging, like all other libraries do.
By this do you mean a plugin, client option, or a class from a package passed as the client option/static property on the class?
from framework.
Sounds good, although the built-in logger will probably have opt-in logging, like all other libraries do.
By this do you mean a plugin, client option, or a class from a package passed as the client option/static property on the class?
As in, the minimum will be set by default to a number higher than LogLevel.Fatal
so nothing is logged, and this would be set with ClientOptions.Logger.Level
. Keep in mind the default logger will simply do calls to Node.js's built-in console and will therefore not format arguments nor add colours - it's not the framework's responsibility, and would certainly make it opinionated to force a dependency (or more, given colours + timestamp) to format logs, as some people will most likely override this logger with something, say a Winston-based or a Klasa-based one.
Plugin can still set this.logger = new MyCustomLogger();
after initialization to override this behaviour completely.
from framework.
As in, the minimum will be set by default to a number higher than
LogLevel.Fatal
so nothing is logged, and this would be set withClientOptions.Logger.Level
.
I think some amount of error logging by default would be reasonable. Users can always disable it if they don't want it, and enabling some errors by default would help new users of the library.
from framework.
As in, the minimum will be set by default to a number higher than
LogLevel.Fatal
so nothing is logged, and this would be set withClientOptions.Logger.Level
.I think some amount of error logging by default would be reasonable. Users can always disable it if they don't want it, and enabling some errors by default would help new users of the library.
In my opinion it should be that theres a @sapphire/logging package which exports the base of the logger class or well interface. Followed by Framework using it with plain console logs or colourette and then if the user wishes to overwrite that they can pass a new instance of their own logger following the design of the interface.
from framework.
As in, the minimum will be set by default to a number higher than
LogLevel.Fatal
so nothing is logged, and this would be set withClientOptions.Logger.Level
.I think some amount of error logging by default would be reasonable. Users can always disable it if they don't want it, and enabling some errors by default would help new users of the library.
In my opinion it should be that theres a @sapphire/logging package which exports the base of the logger class or well interface. Followed by Framework using it with plain console logs or colourette and then if the user wishes to overwrite that they can pass a new instance of their own logger following the design of the interface.
That sounds like it'll work, but if there's nothing major to it, having it within the framework should be fine.
from framework.
As in, the minimum will be set by default to a number higher than
LogLevel.Fatal
so nothing is logged, and this would be set withClientOptions.Logger.Level
.I think some amount of error logging by default would be reasonable. Users can always disable it if they don't want it, and enabling some errors by default would help new users of the library.
In my opinion it should be that theres a @sapphire/logging package which exports the base of the logger class or well interface. Followed by Framework using it with plain console logs or colourette and then if the user wishes to overwrite that they can pass a new instance of their own logger following the design of the interface.
That sounds like it'll work, but if there's nothing major to it, having it within the framework should be fine.
Seems a bit bloated to have the structure for it in the framework since then if someone wishes to just create a package with a logger they would need the whole framework as the dep oppose to just the structure dependency.
from framework.
As in, the minimum will be set by default to a number higher than
LogLevel.Fatal
so nothing is logged, and this would be set withClientOptions.Logger.Level
.I think some amount of error logging by default would be reasonable. Users can always disable it if they don't want it, and enabling some errors by default would help new users of the library.
In my opinion it should be that theres a @sapphire/logging package which exports the base of the logger class or well interface. Followed by Framework using it with plain console logs or colourette and then if the user wishes to overwrite that they can pass a new instance of their own logger following the design of the interface.
That sounds like it'll work, but if there's nothing major to it, having it within the framework should be fine.
Seems a bit bloated to have the structure for it in the framework since then if someone wishes to just create a package with a logger they would need the whole framework as the dep oppose to just the structure dependency.
I mean if the purpose for their package is to work with sapphire, I don't see why they'd mind not having it as dependency.
from framework.
Related Issues (20)
- request: update `Args` to support Chat Input commands HOT 1
- bug: Cannot find namespace "ChatInputCommand" from example code in guide HOT 2
- bug: incorrect conversions in object hashing HOT 1
- request: update for DiscordJS v14
- bug: setting `dm_permission` on guildonly command breaks difference
- request: only fetch guild commands for guilds that have commands associated
- bug: missing required args causes an "unwrap failed" error HOT 1
- bug: Calling Args#rest will include leading space
- RFC: Sapphire directory and automatic TypeScript augmentation support
- request: Can we have a support for discord.js-light HOT 5
- request: [CoreReady listener] automatically delete application commands not found in the Command store
- request: add `RegisterBehavior.BulkOverwrite`
- bug: Command#reload and CommandStore#loadAll do not handle BulkOverwrite
- request: Cog system HOT 2
- Suggestion for args.pick('member')
- bug: Not compatible with bun runtime HOT 5
- [SFW-81] bug: application command comparison failing causing command with no actual changes to get re-registered on every launch HOT 2
- request: e2e testing implementation HOT 2
- request: rawName property for context commands
- request: setPresence.status uses a custom type, but could use readily available PresenceUpdateStatus enum. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from framework.