Class: Nutritionix::APILogger

Inherits:
Object
  • Object
show all
Defined in:
lib/nutritionix/api_1_1.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger = nil, file = File.join(Dir.home, 'nutritionix_api_logs.txt')) ⇒ APILogger

Returns a new instance of APILogger.

Parameters:

  • logger (defaults to: nil)

    the logger instance to be used for logging

  • file.

    Default outputs log to <HOME_DIR>/nutritionix_api_logs.txt



190
191
192
193
# File 'lib/nutritionix/api_1_1.rb', line 190

def initialize(logger=nil, file=File.join(Dir.home, 'nutritionix_api_logs.txt'))
  @file = file
  @logger_instance = logger || Logger.new(@file)
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



186
187
188
# File 'lib/nutritionix/api_1_1.rb', line 186

def file
  @file
end

#logger_instanceObject (readonly)

Returns the value of attribute logger_instance.



185
186
187
# File 'lib/nutritionix/api_1_1.rb', line 185

def logger_instance
  @logger_instance
end

Class Method Details

.default_loggerObject

Returns the default logger(Logger) instance distributed by Ruby in its standard library.



197
198
199
200
# File 'lib/nutritionix/api_1_1.rb', line 197

def self.default_logger
  logger = APILogger.new
  logger.logger_instance
end