Class: RbSys::Util::Logger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io: $stderr, level: :info) ⇒ Logger

Returns a new instance of Logger.



8
9
10
11
# File 'lib/rb_sys/util/logger.rb', line 8

def initialize(io: $stderr, level: :info)
  @io = ENV["GITHUB_ACTIONS"] ? $stdout : io
  @level = level
end

Instance Attribute Details

#ioObject

Returns the value of attribute io.



6
7
8
# File 'lib/rb_sys/util/logger.rb', line 6

def io
  @io
end

#levelObject

Returns the value of attribute level.



6
7
8
# File 'lib/rb_sys/util/logger.rb', line 6

def level
  @level
end

Instance Method Details

#error(message, **opts) ⇒ Object



13
14
15
# File 'lib/rb_sys/util/logger.rb', line 13

def error(message, **opts)
  add(:error, message, **opts)
end

#fatal(message, **opts) ⇒ Object



35
36
37
38
# File 'lib/rb_sys/util/logger.rb', line 35

def fatal(message, **opts)
  error(message, **opts)
  abort
end

#info(message, **opts) ⇒ Object



21
22
23
# File 'lib/rb_sys/util/logger.rb', line 21

def info(message, **opts)
  add(:info, message, **opts)
end

#notice(message, **opts) ⇒ Object



25
26
27
# File 'lib/rb_sys/util/logger.rb', line 25

def notice(message, **opts)
  add(:notice, message, **opts)
end

#trace(message, **opts) ⇒ Object



29
30
31
32
33
# File 'lib/rb_sys/util/logger.rb', line 29

def trace(message, **opts)
  return unless level == :trace

  add(:trace, message, **opts)
end

#warn(message, **opts) ⇒ Object



17
18
19
# File 'lib/rb_sys/util/logger.rb', line 17

def warn(message, **opts)
  add(:warn, message, **opts)
end