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

Accept log messages via block #28

Merged
merged 3 commits into from
May 10, 2024
Merged

Conversation

komidore64
Copy link
Contributor

@komidore64 komidore64 commented May 1, 2024

fixes #25


This patch allows a Dry-Logger instance to accept log messages via a block.

If a block is passed to #unknown, #debug, #info, #warn, #error, or
#fatal, the block's return value becomes the logged message much like the
Ruby standardlib Logger.

l = Dry.Logger(:testymctestface, template: :details)
# => #<Dry::Logger::Dispatcher ...

l.info('regular positional argument message')
# [testymctestface] [INFO] [2024-05-01 07:35:36 -0400] regular positional argument message
# => true

l.info { 'a block message' }
# [testymctestface] [INFO] [2024-05-01 07:35:50 -0400] a block message
# => true

l.info('sub-component') { 'fancy-pants block message' }
# [sub-component] [INFO] [2024-05-01 07:36:09 -0400] fancy-pants block message
# => true

I added two spec tests to ensure that block passing works, but I wasn't able to
quickly figure out how to check the value of progname.


Thank you for considering my patch!

@komidore64
Copy link
Contributor Author

@timriley this is ready for your eyes!

@timriley
Copy link
Member

timriley commented May 2, 2024

@komidore64 This is fantastic, thank you!

I've just pushed up some expanded (and passing) tests for the progname handling. Does that behaviour match your expectations?

If you're happy with that, then I can get this in and cut a new release.

@komidore64
Copy link
Contributor Author

@komidore64 This is fantastic, thank you!

I've just pushed up some expanded (and passing) tests for the progname handling. Does that behaviour match your expectations?

I appreciate the assistance. It does! It didn't occur to me that passing progname as a kwarg would also work. I'm glad dry-logger users will have plenty of options.

If you're happy with that, then I can get this in and cut a new release.

I am happy with this. That'd be great!

Thank you for the quick turnaround.

@komidore64
Copy link
Contributor Author

@timriley do you need anything else from me to move this forward? I'm happy to help however I can.

@timriley timriley changed the title accept log messages via block Accept log messages via block May 10, 2024
@timriley
Copy link
Member

@komidore64 Thank you for checking in! I've just got this ready now (had to sort out a few test failures on the main branch first). I'm going to merge this now and then cut a release. Thanks again!

@timriley timriley merged commit 1679541 into dry-rb:main May 10, 2024
5 checks passed
@timriley
Copy link
Member

This is released as v1.0.4. Thanks again @komidore64!

@komidore64 komidore64 deleted the accept-block branch May 10, 2024 13:24
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.

Dry::Logger ignores log-payloads passed by block
2 participants