Class: Kamal::Output::BaseLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/kamal/output/base_logger.rb

Direct Known Subclasses

FileLogger, OtelLogger

Instance Method Summary collapse

Constructor Details

#initializeBaseLogger

Returns a new instance of BaseLogger.



4
5
6
7
# File 'lib/kamal/output/base_logger.rb', line 4

def initialize
  super(nil)
  @subscription = ActiveSupport::Notifications.subscribe("modify.kamal", self)
end

Instance Method Details

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



19
20
21
22
23
# File 'lib/kamal/output/base_logger.rb', line 19

def add(severity, message = nil, progname = nil, &block)
  if msg = message || (block ? block.call : progname)
    self << msg.to_s
  end
end

#closeObject



25
26
27
28
# File 'lib/kamal/output/base_logger.rb', line 25

def close
  ActiveSupport::Notifications.unsubscribe(@subscription)
  on_close
end

#finish(name, id, payload) ⇒ Object



14
15
16
17
# File 'lib/kamal/output/base_logger.rb', line 14

def finish(name, id, payload)
  runtime = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - @started_at).round(1)
  on_finish(payload, runtime)
end

#start(name, id, payload) ⇒ Object



9
10
11
12
# File 'lib/kamal/output/base_logger.rb', line 9

def start(name, id, payload)
  @started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  on_start(payload)
end