Class: Tfctl::Logger
- Inherits:
-
Object
- Object
- Tfctl::Logger
- Defined in:
- lib/tfctl/logger.rb
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #fatal(msg) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(log_level) ⇒ Logger
constructor
A new instance of Logger.
- #level ⇒ Object
- #level=(level) ⇒ Object
- #log(level, msg) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
#initialize(log_level) ⇒ Logger
Returns a new instance of Logger.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/tfctl/logger.rb', line 8 def initialize(log_level) @outlog = ::Logger.new(STDOUT) self.level = log_level @outlog.formatter = proc do |severity, _datetime, _progname, msg| # "#{datetime.iso8601} #{severity.downcase}: #{msg}\n" "#{severity.downcase}: #{msg}\n" end end |
Instance Method Details
#debug(msg) ⇒ Object
27 28 29 |
# File 'lib/tfctl/logger.rb', line 27 def debug(msg) log(:debug, msg) end |
#error(msg) ⇒ Object
39 40 41 |
# File 'lib/tfctl/logger.rb', line 39 def error(msg) log(:error, msg) end |
#fatal(msg) ⇒ Object
43 44 45 |
# File 'lib/tfctl/logger.rb', line 43 def fatal(msg) log(:fatal, msg) end |
#info(msg) ⇒ Object
31 32 33 |
# File 'lib/tfctl/logger.rb', line 31 def info(msg) log(:info, msg) end |
#level ⇒ Object
23 24 25 |
# File 'lib/tfctl/logger.rb', line 23 def level @outlog.level end |
#level=(level) ⇒ Object
19 20 21 |
# File 'lib/tfctl/logger.rb', line 19 def level=(level) @outlog.level = level end |
#log(level, msg) ⇒ Object
47 48 49 |
# File 'lib/tfctl/logger.rb', line 47 def log(level, msg) @outlog.send(level, msg) end |
#warn(msg) ⇒ Object
35 36 37 |
# File 'lib/tfctl/logger.rb', line 35 def warn(msg) log(:warn, msg) end |