Skip to content
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

Add syntax for the Logger #568

Merged
merged 5 commits into from
Jan 13, 2022
Merged

Conversation

danicheg
Copy link
Member

This adds syntax that allows logging in that way:

def log[F[_]: Sync: Logger] = 
  for {
    result1 <- successComputation[F]
    _ <- info"First result is $result1"
    _ <- errorComputation[F].onError(_ => error"We got an error!")
  } yield ()

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever, but I'm not sure that I'd use it. Open to what others think.

@danicheg
Copy link
Member Author

danicheg commented Jan 2, 2022

@ChristopherDavenport would you check this, please?

@danicheg
Copy link
Member Author

No one else hasn't expressed an opinion about this 😞 I'd be happy if can to decide on our own.

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to refer to lexically-scoped loggers that log to a known category, rather than pass them as constraints, where I'm not sure what category they'll log to. Nor do I usually care to track logging as a capability. So I can't imagine myself using this.

However, you like it, it doesn't pollute the namespace without an import, and it doesn't bring in any dependencies. It's good for you and it won't hurt me. I say your 👍 weighs more than my 👎.

@danicheg
Copy link
Member Author

Thanks! Personally, I'm 50/50 about using logging via capabilities. But there is well known in one coterie logging library (tofu-logging), which promotes this approach pretty much. Therefore thinking about users familiar with that approach, it could be nice to have it in our's arsenal.

@danicheg danicheg merged commit 1ddc944 into typelevel:series/1.x Jan 13, 2022
@danicheg danicheg deleted the series/1.x-syntax branch January 13, 2022 08:56
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.

2 participants