Module: ImportTools::ImportLogging::Include

Included in:
HammerCLIImport::BaseCommand, HammerCLIImport::ImportCommand::AllCommand
Defined in:
lib/hammer_cli_import/importtools.rb

Instance Method Summary collapse

Instance Method Details

#debug(s) ⇒ Object



278
279
280
# File 'lib/hammer_cli_import/importtools.rb', line 278

def debug(s)
  log(Logger::DEBUG, s)
end

#error(s) ⇒ Object



294
295
296
# File 'lib/hammer_cli_import/importtools.rb', line 294

def error(s)
  log(Logger::ERROR, s)
end

#fatal(s) ⇒ Object



298
299
300
# File 'lib/hammer_cli_import/importtools.rb', line 298

def fatal(s)
  log(Logger::FATAL, s)
end

#info(s) ⇒ Object



282
283
284
# File 'lib/hammer_cli_import/importtools.rb', line 282

def info(s)
  log(Logger::INFO, s)
end

#log(lvl, s, always = false) ⇒ Object



306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/hammer_cli_import/importtools.rb', line 306

def log(lvl, s, always = false)
  @logger.log(lvl, s)
  return if option_quiet?

  if always
    puts s
  elsif option_verbose?
    puts s if lvl >= @curr_lvl
  else
    puts s if lvl > @curr_lvl
  end
end

#logtrace(e) ⇒ Object



302
303
304
# File 'lib/hammer_cli_import/importtools.rb', line 302

def logtrace(e)
  @logger.log(Logger::ERROR, (e.backtrace.join "\n"))
end

#progress(s) ⇒ Object



286
287
288
# File 'lib/hammer_cli_import/importtools.rb', line 286

def progress(s)
  log(Logger::INFO, s, true)
end

#setup_loggingObject



270
271
272
273
274
275
276
# File 'lib/hammer_cli_import/importtools.rb', line 270

def setup_logging
  @curr_lvl = Logger::INFO
  @curr_lvl = Logger::DEBUG if option_debug?

  @logger = Logger.new(File.new(option_logfile, 'a'))
  @logger.level = @curr_lvl
end

#warn(s) ⇒ Object



290
291
292
# File 'lib/hammer_cli_import/importtools.rb', line 290

def warn(s)
  log(Logger::WARN, s)
end