module NutritionCalculator::HasLogging
Provides a few logging utilities to the including class/module
Attributes
logger[W]
Public Instance Methods
logger()
click to toggle source
The logger to which the including class/module should write
Defaults to a NullLogger
, which simply discards all logging attempts as noops.
@return [Logger] an object adhering to the Logger interface
# File lib/nutrition_calculator/has_logging.rb, line 25 def logger @logger ||= NullLogger end
Protected Instance Methods
debug_value(name, &block)
click to toggle source
Executes the block and both logs and returns the result
@return [block.call] The result of calling the block provided
# File lib/nutrition_calculator/has_logging.rb, line 34 def debug_value(name, &block) block.call.tap do |value| logger.debug("#{name}: #{value}") end end