Module: Flub
- Defined in:
- lib/flub.rb,
lib/flub/version.rb
Defined Under Namespace
Classes: NullLogger
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
- .configure(&block) ⇒ Object
- .logger(l = :default) ⇒ Object
- .on_error(&block) ⇒ Object
- .register_exception(e, data = {}, log_level = :error) ⇒ Object
- .with_data(hash) ⇒ Object
Class Method Details
.configure(&block) ⇒ Object
6 7 8 |
# File 'lib/flub.rb', line 6 def configure &block instance_eval(&block) end |
.logger(l = :default) ⇒ Object
30 31 32 33 34 |
# File 'lib/flub.rb', line 30 def logger l = :default @logger = l if l != :default @logger ||= NullLogger.new end |
.on_error(&block) ⇒ Object
10 11 12 13 |
# File 'lib/flub.rb', line 10 def on_error &block @on_error ||= [] @on_error << block end |
.register_exception(e, data = {}, log_level = :error) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flub.rb', line 19 def register_exception e, data = {}, log_level = :error @on_error.each do |handler| begin handler.call e, data, log_level rescue StandardError => e logger.error "#{self.class}#register_exception failed" logger.error "#{e.class} - #{e.}" end end end |
.with_data(hash) ⇒ Object
15 16 17 |
# File 'lib/flub.rb', line 15 def with_data hash yield end |