Skip to content

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

morgen-peschke
Copy link
Contributor

Implements #911

If there's interest, I'll figure out how to add some tests to this.

Comment on lines 42 to 45
/**
* Because there is no `log4j` backend, the log level can be set directly
*/
def setLogLevel(level: LogLevel): F[Unit]
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants