Class: Cogger::Hub
Overview
Loads configuration and simultaneously sends messages to multiple streams. :reek:TooManyInstanceVariables :reek:TooManyMethods
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
- #info(message = nil) ⇒ Object
-
#initialize(registry: Cogger, model: Configuration, **attributes) ⇒ Hub
constructor
A new instance of Hub.
- #inspect ⇒ Object
- #reread ⇒ Object
- #warn(message = nil) ⇒ Object
Constructor Details
#initialize(registry: Cogger, model: Configuration, **attributes) ⇒ Hub
Returns a new instance of Hub.
39 40 41 42 43 44 45 |
# File 'lib/cogger/hub.rb', line 39 def initialize(registry: Cogger, model: Configuration, **attributes) @registry = registry @configuration = model[**find_formatter(attributes)] @primary = configuration.to_logger @streams = [@primary] @mutex = Mutex.new end |
Instance Method Details
#abort(message = nil, **payload, &block) ⇒ Object
65 66 67 68 |
# File 'lib/cogger/hub.rb', line 65 def abort( = nil, **payload, &block) error(, **payload, &block) if || !payload.empty? || block exit false end |
#add(level, message = nil) ⇒ Object
70 71 72 |
# File 'lib/cogger/hub.rb', line 70 def add(level, = nil, **, &) log(Logger::SEV_LABEL.fetch(level, "ANY").downcase, , **, &) end |
#add_stream(**attributes) ⇒ Object
47 48 49 50 51 |
# File 'lib/cogger/hub.rb', line 47 def add_stream **attributes attributes[:id] = configuration.id streams.append configuration.with(**find_formatter(attributes)).to_logger self end |
#any(message = nil) ⇒ Object Also known as: unknown
63 |
# File 'lib/cogger/hub.rb', line 63 def any( = nil, **, &) = log(__method__, , **, &) |
#debug(message = nil) ⇒ Object
53 |
# File 'lib/cogger/hub.rb', line 53 def debug( = nil, **, &) = log(__method__, , **, &) |
#error(message = nil) ⇒ Object
59 |
# File 'lib/cogger/hub.rb', line 59 def error( = nil, **, &) = log(__method__, , **, &) |
#fatal(message = nil) ⇒ Object
61 |
# File 'lib/cogger/hub.rb', line 61 def fatal( = nil, **, &) = log(__method__, , **, &) |
#info(message = nil) ⇒ Object
55 |
# File 'lib/cogger/hub.rb', line 55 def info( = nil, **, &) = log(__method__, , **, &) |
#inspect ⇒ Object
78 79 80 |
# File 'lib/cogger/hub.rb', line 78 def inspect %(#<#{self.class} #{configuration.inspect.delete_prefix! "#<Cogger::Configuration "}) end |
#reread ⇒ Object
76 |
# File 'lib/cogger/hub.rb', line 76 def reread = primary.reread |
#warn(message = nil) ⇒ Object
57 |
# File 'lib/cogger/hub.rb', line 57 def warn( = nil, **, &) = log(__method__, , **, &) |