Class: Bridgetown::Rack::Logger

Inherits:
LogWriter
  • Object
show all
Defined in:
lib/bridgetown-core/rack/logger.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LogWriter

#close, #error, #warn

Constructor Details

#initialize(*_args) ⇒ Logger

Returns a new instance of Logger.



25
26
27
28
# File 'lib/bridgetown-core/rack/logger.rb', line 25

def initialize(*_args)
  super()
  enable_prefix
end

Class Method Details

.message_with_prefix(msg) ⇒ Object



9
10
11
# File 'lib/bridgetown-core/rack/logger.rb', line 9

def self.message_with_prefix(msg)
  "\e[35m[Server]\e[0m #{msg}"
end

Instance Method Details

#add(severity, message = nil, progname = nil) ⇒ Object



19
20
21
22
23
# File 'lib/bridgetown-core/rack/logger.rb', line 19

def add(severity, message = nil, progname = nil)
  return if progname&.include?("/_bridgetown/live_reload")

  super
end

#enable_prefixObject



13
14
15
16
17
# File 'lib/bridgetown-core/rack/logger.rb', line 13

def enable_prefix
  @formatter = proc do |_, _, _, msg|
    self.class.message_with_prefix(msg)
  end
end