Class: BbDeploy::Logger::ConsolidatedLogger::Logentries
- Inherits:
-
Object
- Object
- BbDeploy::Logger::ConsolidatedLogger::Logentries
- Defined in:
- lib/bb_deploy/logger.rb
Overview
For logging to our Logentries consolidated logging service
Instance Method Summary collapse
-
#initialize(phase) ⇒ Logentries
constructor
A new instance of Logentries.
-
#logger ⇒ Object
Logs originating here will be found in the BB Logentries account in the “Ruby Log” for each phase.
- #method_missing(method, *args) ⇒ Object
- #with_consolidated_logging ⇒ Object
-
#write(msg) ⇒ Object
To replace $stdout we must #write.
Constructor Details
#initialize(phase) ⇒ Logentries
Returns a new instance of Logentries.
10 11 12 |
# File 'lib/bb_deploy/logger.rb', line 10 def initialize(phase) @phase = phase end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
32 33 34 |
# File 'lib/bb_deploy/logger.rb', line 32 def method_missing(method, *args) # this is mostly a call to #flush. We do nothing. end |
Instance Method Details
#logger ⇒ Object
Logs originating here will be found in the BB Logentries account in the “Ruby Log” for each phase
38 39 40 |
# File 'lib/bb_deploy/logger.rb', line 38 def logger @logger ||= Le.new(BbDeploy::Config.logentries_token) end |
#with_consolidated_logging ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bb_deploy/logger.rb', line 14 def with_consolidated_logging @original_stdout = $stdout # Logging something before assigning $stdout is necessary # to avoid `SystemStackError: stack level too deep`?! logger.send(:info, "logging #with_consolidated_logging") $stdout = self yield ensure $stdout = @original_stdout end |
#write(msg) ⇒ Object
To replace $stdout we must #write
26 27 28 29 30 |
# File 'lib/bb_deploy/logger.rb', line 26 def write(msg) # Apparently reassigning $stdout triggers a blank message. @original_stdout.puts(msg) logger.send(:info, "#{ENV['USER']} #{msg}") unless msg.blank? end |