Class: Locomotive::Steam::Logger
- Inherits:
-
Object
- Object
- Locomotive::Steam::Logger
- Defined in:
- lib/locomotive/steam/logger.rb
Instance Attribute Summary collapse
-
#logfile_path ⇒ Object
Returns the value of attribute logfile_path.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
-
#setup(path, stdout = false) ⇒ Object
Setup the single instance of the ruby logger.
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
8 9 10 |
# File 'lib/locomotive/steam/logger.rb', line 8 def initialize self.logger = nil end |
Instance Attribute Details
#logfile_path ⇒ Object
Returns the value of attribute logfile_path.
6 7 8 |
# File 'lib/locomotive/steam/logger.rb', line 6 def logfile_path @logfile_path end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/locomotive/steam/logger.rb', line 6 def logger @logger end |
#stdout ⇒ Object
Returns the value of attribute stdout.
6 7 8 |
# File 'lib/locomotive/steam/logger.rb', line 6 def stdout @stdout end |
Class Method Details
.instance ⇒ Object
35 36 37 |
# File 'lib/locomotive/steam/logger.rb', line 35 def self.instance @@instance ||= self.new end |
.setup(path, stdout = false) ⇒ Object
39 40 41 |
# File 'lib/locomotive/steam/logger.rb', line 39 def self.setup(path, stdout = false) self.instance.setup(path, stdout) end |
Instance Method Details
#setup(path, stdout = false) ⇒ Object
Setup the single instance of the ruby logger.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/locomotive/steam/logger.rb', line 17 def setup(path, stdout = false) require 'logger' self.stdout = stdout self.logfile_path = File.(File.join(path, 'log', 'steam.log')) FileUtils.mkdir_p(File.dirname(logfile_path)) out = self.stdout ? STDOUT : self.logfile_path self.logger = ::Logger.new(out).tap do |log| log.level = ::Logger::DEBUG log.formatter = proc do |severity, datetime, progname, msg| "#{msg}\n" end end end |