dry-logger
                                
                                
                                
                                    dry-logger copied to clipboard
                            
                            
                            
                        accept log messages via block
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!
@timriley this is ready for your eyes!
@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 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.
@timriley do you need anything else from me to move this forward? I'm happy to help however I can.
@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!
This is released as v1.0.4. Thanks again @komidore64!