Module: MailHandler::Logger
- Defined in:
- lib/logger/logger.rb,
lib/initializers/logger.rb
Overview
Initializes the logger from config
Class Method Summary collapse
Class Method Details
.error(args) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/logger/logger.rb', line 17 def error(args) str = "\n" str << "ERROR: #{args[:error_type]}\n--\n" if args[:error_type] str << "Error code: #{args[:error_code]}\n--\n" if args[:error_code] str << "Subject: #{args[:subject]}\n--\n" if args[:subject] str << "Trace: #{args[:trace]}\n--\n" if args[:trace] str << "==\n" log str end |
.log(string) ⇒ Object
27 28 29 |
# File 'lib/logger/logger.rb', line 27 def log(string) @logfile ? @logfile.puts(string) : puts(string) end |
.setup(config) ⇒ Object
7 8 9 10 11 |
# File 'lib/logger/logger.rb', line 7 def setup(config) if config @logfile = File.open(config[:log_file], 'a') if config[:log_file] end end |
.success(args) ⇒ Object
13 14 15 |
# File 'lib/logger/logger.rb', line 13 def success(args) log "SUCCESS: #{args[:subject]}" end |