Module: Itrigga

Defined in:
lib/itrigga/admin_api_client/proxies/api.rb,
lib/itrigga/admin_api_client/proxies/admin.rb,
lib/itrigga/admin_api_client/admin_api_client.rb,
lib/itrigga/admin_api_client/proxies/search_tracker.rb

Defined Under Namespace

Modules: AdminApiClient

Class Method Summary collapse

Class Method Details

.add_log_line(line, add_padding = false) ⇒ Object

Prints a debugging info line into the log…



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/itrigga/admin_api_client/admin_api_client.rb', line 62

def self.add_log_line(line, add_padding = false)
  is_terminal = false
  begin
    @terminal_width ||= `stty size`.split.map { |x| x.to_i }.reverse[0]
    is_terminal = true
  rescue Exception => e
    # not running in terminal``
  end
  
  if add_padding and is_terminal and !@terminal_width.nil?
    puts  "#{line.ljust(@terminal_width - line.length, "=")}\n"
  else
    if defined?(Rails.logger)
      Rails.logger.info line
    else
      puts line
    end
  end
end