Class: PgObjects::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_objects/logger.rb

Overview

Console output with severity levels. Writes to the injected stream (default $stdout). With config.silent enabled, +info+/+warn+ messages are suppressed; error messages are always written.

Instance Method Summary collapse

Constructor Details

#initialize(stream: $stdout, **deps) ⇒ Logger

Returns a new instance of Logger.



10
11
12
13
# File 'lib/pg_objects/logger.rb', line 10

def initialize(stream: $stdout, **deps)
  super(**deps)
  @stream = stream
end

Instance Method Details

#error(str) ⇒ Object



28
29
30
# File 'lib/pg_objects/logger.rb', line 28

def error(str)
  log("[ERROR] #{str}", force: true)
end

#info(str) ⇒ Object



20
21
22
# File 'lib/pg_objects/logger.rb', line 20

def info(str)
  log(str)
end

#warn(str) ⇒ Object



24
25
26
# File 'lib/pg_objects/logger.rb', line 24

def warn(str)
  log("[WARN] #{str}")
end

#write(str) ⇒ Object

Backward-compatible entry point; behaves like info.



16
17
18
# File 'lib/pg_objects/logger.rb', line 16

def write(str)
  log(str)
end