Class: Gemstash::Logging::StreamLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/gemstash/logging.rb

Overview

Logger that looks like a stream, for Puma and Rack to log to.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ StreamLogger

Returns a new instance of StreamLogger.



74
75
76
# File 'lib/gemstash/logging.rb', line 74

def initialize(level)
  @level = level
end

Class Method Details

.for_stderrObject



70
71
72
# File 'lib/gemstash/logging.rb', line 70

def self.for_stderr
  new(Logger::ERROR)
end

.for_stdoutObject



66
67
68
# File 'lib/gemstash/logging.rb', line 66

def self.for_stdout
  new(Logger::INFO)
end

.puma_eventsObject



62
63
64
# File 'lib/gemstash/logging.rb', line 62

def self.puma_events
  Puma::Events.new(for_stdout, for_stderr)
end

Instance Method Details

#flushObject



78
79
# File 'lib/gemstash/logging.rb', line 78

def flush
end

#puts(message) ⇒ Object



88
89
90
# File 'lib/gemstash/logging.rb', line 88

def puts(message)
  Gemstash::Logging.logger.add(@level, message)
end

#sync=(_value) ⇒ Object



81
82
# File 'lib/gemstash/logging.rb', line 81

def sync=(_value)
end

#write(message) ⇒ Object



84
85
86
# File 'lib/gemstash/logging.rb', line 84

def write(message)
  Gemstash::Logging.logger.add(@level, message)
end