Module: LogHelpers

Included in:
FeatureSelection::Base
Defined in:
lib/feature_selection/log_helpers.rb

Instance Method Summary collapse

Instance Method Details

#create_log(log_to) ⇒ Object

2 outcomes

  • Filepath given: create a log to that file

  • Logger object given: write to that object



7
8
9
10
11
12
13
# File 'lib/feature_selection/log_helpers.rb', line 7

def create_log(log_to)
  if log_to.is_a?(Logger)
    @log = log_to
  else
    @log = Logger.new(log_to)
  end
end

#log_calculations_complete(n, other_text = '') ⇒ Object

Writes the number of calculations completed to the log



22
23
24
# File 'lib/feature_selection/log_helpers.rb', line 22

def log_calculations_complete(n, other_text='')
  write_to_log("#{n}/#{total_calculations} #{other_text} calculations complete.")
end

#write_to_log(message) ⇒ Object



15
16
17
18
19
# File 'lib/feature_selection/log_helpers.rb', line 15

def write_to_log(message)
  if @log
    @log.info(message)
  end
end