class BbDeploy::Logger::ConsolidatedLogger::Logentries
For logging to our Logentries
consolidated logging service
Public Class Methods
new(phase)
click to toggle source
# File lib/bb_deploy/logger.rb, line 10 def initialize(phase) @phase = phase end
Public Instance Methods
logger()
click to toggle source
Logs originating here will be found in the BB Logentries
account in the “Ruby Log” for each phase
# File lib/bb_deploy/logger.rb, line 38 def logger @logger ||= Le.new(BbDeploy::Config.logentries_token) end
method_missing(method, *args)
click to toggle source
# File lib/bb_deploy/logger.rb, line 32 def method_missing(method, *args) # this is mostly a call to #flush. We do nothing. end
with_consolidated_logging() { || ... }
click to toggle source
# 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)
click to toggle source
To replace $stdout we must write
# 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