-
Notifications
You must be signed in to change notification settings - Fork 83
Add a ConsoleLogger and ConsoleLoggerFactory #912
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
base: main
Are you sure you want to change the base?
Add a ConsoleLogger and ConsoleLoggerFactory #912
Conversation
core/shared/src/main/scala/org/typelevel/log4cats/extras/ConsoleLogger.scala
Outdated
Show resolved
Hide resolved
/** | ||
* Because there is no `log4j` backend, the log level can be set directly | ||
*/ | ||
def setLogLevel(level: LogLevel): F[Unit] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that setLogLevel
belongs to the Logger? As far as I can tell, that API usually corresponds to a Logger factory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I exposed it in both locations because I didn't want to force the creation of a LoggerFactory
for a situation where a one-off script just needed a single logger.
I'm not particularly wedded to that as a matter of principle.
* limitations under the License. | ||
*/ | ||
|
||
package org.typelevel.log4cats.extras |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have the dedicated js-console
module that exposes ConsoleLogger
for JS. Shouldn't we either create a new module for JVM/Native to maintain consistency (perhaps extras
would be fine), or at the very least move the new ConsoleLogger
to a JVM/Native-specific submodule, so it's only published for the mentioned platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really have the setup, but I'm kind of curious what this would do in JS. I'd assume that Console
has an implementation on that platform 🤔
It's all going on stderr, so I'd be open to renaming it StdErrLogger
to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought part of the goal was to have this available in core, without depending on other modules? Otherwise, I'd think we'd just use slf4j and slf4j-simple?
Implements #911
If there's interest, I'll figure out how to add some tests to this.