Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use hanami logger?

can you give examples of using hanami logger? I found some controversial Examples, some says it is already inside hanami(and you can use just logger.info('test'), unfortunately at least for me it is not working, I only see config for logger inside environment.rb), some says you need to install gem hanami-utils, then

require 'hanami/logger'
logger = Hanami::Logger.new('Test', level: 'info')
logger.info('test')

It works, but how to require it to all modules? Or only way to use global variables and say rubocop don't worry on every logger line? Sorry for may be stupid question ruby and hanami is new world for me.

like image 299
Mikhail Levin Avatar asked Dec 07 '25 07:12

Mikhail Levin


1 Answers

The Hanami.logger is part of a Hanami App. It is loaded automatically, so can use it without requiring.

Hanami.logger.debug("Hello")

You can do some logging configuration at config/environment.rb

If you need special behavior you could use a custom logger

like image 146
wuarmin Avatar answered Dec 08 '25 23:12

wuarmin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!