Class: Cogger::Hub
Overview
Loads configuration and simultaneously sends messages to multiple streams.
Instance Method Summary collapse
- #abort(message = nil, **payload, &block) ⇒ Object
- #add(level, message = nil) ⇒ Object
- #add_stream(**attributes) ⇒ Object
- #any(message = nil) ⇒ Object (also: #unknown)
- #debug(message = nil) ⇒ Object
- #error(message = nil) ⇒ Object
- #fatal(message = nil) ⇒ Object
- #formatter=(value) ⇒ Object
- #info(message = nil) ⇒ Object
-
#initialize(registry: Cogger, model: Configuration, **attributes) ⇒ Hub
constructor
A new instance of Hub.
- #inspect ⇒ Object
- #panic(message = nil, **payload, &block) ⇒ Object
- #reread ⇒ Object
- #warn(message = nil) ⇒ Object
Constructor Details
#initialize(registry: Cogger, model: Configuration, **attributes) ⇒ Hub
Returns a new instance of Hub.
35 36 37 38 39 40 |
# File 'lib/cogger/hub.rb', line 35 def initialize registry: Cogger, model: Configuration, **attributes @registry = registry @configuration = model[**resolve_formatter(attributes)] @primary = configuration.to_logger @streams = [@primary] end |
Instance Method Details
#abort(message = nil, **payload, &block) ⇒ Object
60 61 62 63 |
# File 'lib/cogger/hub.rb', line 60 def abort = nil, **payload, &block error(, **payload, &block) if || !payload.empty? || block exit false end |
#add(level, message = nil) ⇒ Object
74 75 76 |
# File 'lib/cogger/hub.rb', line 74 def add(level, = nil, **, &) log(Logger::SEV_LABEL.fetch(level, "ANY").downcase, , **, &) end |
#add_stream(**attributes) ⇒ Object
42 43 44 45 46 |
# File 'lib/cogger/hub.rb', line 42 def add_stream **attributes attributes[:id] = configuration.id streams.append configuration.with(**resolve_formatter(attributes)).to_logger self end |
#any(message = nil) ⇒ Object Also known as: unknown
58 |
# File 'lib/cogger/hub.rb', line 58 def any( = nil, **, &) = log(__method__, , **, &) |
#debug(message = nil) ⇒ Object
48 |
# File 'lib/cogger/hub.rb', line 48 def debug( = nil, **, &) = log(__method__, , **, &) |
#error(message = nil) ⇒ Object
54 |
# File 'lib/cogger/hub.rb', line 54 def error( = nil, **, &) = log(__method__, , **, &) |
#fatal(message = nil) ⇒ Object
56 |
# File 'lib/cogger/hub.rb', line 56 def fatal( = nil, **, &) = log(__method__, , **, &) |
#formatter=(value) ⇒ Object
70 71 72 |
# File 'lib/cogger/hub.rb', line 70 def formatter= value primary.formatter = find_or_use_formatter value end |
#info(message = nil) ⇒ Object
50 |
# File 'lib/cogger/hub.rb', line 50 def info( = nil, **, &) = log(__method__, , **, &) |
#inspect ⇒ Object
82 83 84 |
# File 'lib/cogger/hub.rb', line 82 def inspect %(#<#{self.class} #{configuration.inspect.delete_prefix! "#<Cogger::Configuration "}) end |
#panic(message = nil, **payload, &block) ⇒ Object
65 66 67 68 |
# File 'lib/cogger/hub.rb', line 65 def panic = nil, **payload, &block fatal(, **payload, &block) if || !payload.empty? || block exit false end |
#reread ⇒ Object
80 |
# File 'lib/cogger/hub.rb', line 80 def reread = primary.reread |
#warn(message = nil) ⇒ Object
52 |
# File 'lib/cogger/hub.rb', line 52 def warn( = nil, **, &) = log(__method__, , **, &) |