-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't print errors (or anything) inside of classes #32
Comments
I'm curious to hear your thoughts on this @amerharb! |
yes agree, moving logging to log.ts was a step one to do that, however IMO I do avoid to use these complicated logging packages that need a lot of configuration that is easy to break, but maybe a simple home made interface and implementation until we need something more advance. |
and yeah regarding not to log error from the class as long as it raise the error, yes I think we should remove remove that. |
I agree that we should not add any logging packages. I realize reading my issue back that the following can be misinterpreted and maybe is why you mention logging packages:
I did not mean that a log message should be sent via HTTP to some logging repository. I just meant that errors should be reported to the user of the program, and if the user is on the command-line, logging it makes sense, but if the user is interacting with the program via a web interface and the error is triggered in an API route, the error needs to be included in the HTTP response so that the UI can show a message. The above is probably so obvious that it goes without saying, but to me that also means that there is no value in logging anything inside a class like |
I was getting a test failure in #31 because
LyraConfig
was usingconsole.error
(indirectly). I didn't realize this before. I think this is something that we should avoid: console logging from within the depths of the program.If we want to use logging, we should create a logger role (i.e. an interface) that can be used by classes that want to log something, and inject that as a dependency rather than using global functions.
But ideally I don't see a need for classes like
LyraConfig
to log errors themselves. They should just raise the error, and the user of the class can decide what is the best way to report the error (logging, HTTP, etc).Besides being IMO just a generally nice principle and separation of concerns, this also means that the code we write now can be reused in other aspects of the future lyra ecosystem, including libraries and (CLI) tooling.
The text was updated successfully, but these errors were encountered: