typelevel / typelevel/log4cats

QoL Feature: A simple console logger

Open
#911 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
416
Forks
77
Avg merge
6h 25m
Merged PRs (30d)
3

Description

While debugging a script, I felt the lack of a simple console logger.

It was a one-off scala-cli script, and adding a logback.xml file with the appropriate cli arguments seemed like a huge hassle just to get logs dumped to standard error.

I ended up adding this to my script, which did the trick, but was annoying and it seems like this could be provided as part of the library as it does not require any additional dependencies:

class StdOutLogger[F[_]: Apply](console: Console[F]) extends Logger[F] {
  override def error(t: Throwable)(message: => String): F[Unit] =
    console.errorln(message) *> console.println(t)

  override def warn(t: Throwable)(message: => String): F[Unit] =
    console.errorln(message) *> console.println(t)

  override def info(t: Throwable)(message: => String): F[Unit] =
    console.errorln(message) *> console.println(t)

  override def debug(t: Throwable)(message: => String): F[Unit] =
    console.errorln(message) *> console.println(t)

  override def trace(t: Throwable)(message: => String): F[Unit] =
    console.errorln(message) *> console.println(t)

  override def error(message: => String): F[Unit] =
    console.errorln(message)

  override def warn(message: => String): F[Unit] =
    console.errorln(message)

  override def info(message: => String): F[Unit] =
    console.errorln(message)

  override def debug(message: => String): F[Unit] =
    console.errorln(message)

  override def trace(message: => String): F[Unit] =
    console.errorln(message)
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing Logger and Console abstractions used by the library, then compare their available operations with the proposed dependency-free implementation. Done should be a supported simple console logger that writes messages and throwables to standard error for the listed log levels, with coverage for its behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.