Class: Valkyrie::Logging
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Valkyrie::Logging
- Defined in:
- lib/valkyrie/logging.rb
Overview
A wrapper class for Valkyrie logging. This class attempts to provide tooling that helps improve the communication through-out the stack.
In gem development there are several considerations regarding logging.
1) The development on the gem directly, in particular specs 2) The downstream development that leverages the gem, both when specs are
running and when running the downstream processes in a development
environment.
3) The downstream behaviors that are called in production environments.
In each of these cases, different considerations regarding logging may be relevant.
In the below example,
Instance Method Summary collapse
- #clear_suppressions!(*logging_contexts) ⇒ Object
- #debug(*args, logging_context: false, &block) ⇒ Object
- #error(*args, logging_context: false, &block) ⇒ Object
- #fatal(*args, logging_context: false, &block) ⇒ Object
- #info(*args, logging_context: false, &block) ⇒ Object
-
#initialize(logger:) ⇒ Logging
constructor
A new instance of Logging.
- #suppress_logging_for_contexts!(*logging_contexts) ⇒ Object
- #warn(*args, logging_context: false, &block) ⇒ Object
Constructor Details
#initialize(logger:) ⇒ Logging
Returns a new instance of Logging.
32 33 34 35 |
# File 'lib/valkyrie/logging.rb', line 32 def initialize(logger:) @suppressions = {} super(logger) end |
Instance Method Details
#clear_suppressions!(*logging_contexts) ⇒ Object
66 67 68 69 70 |
# File 'lib/valkyrie/logging.rb', line 66 def clear_suppressions!(*logging_contexts) Array(logging_contexts).each do |logging_context| @suppressions.delete(logging_context) end end |
#debug(*args, logging_context: false, &block) ⇒ Object
49 50 51 |
# File 'lib/valkyrie/logging.rb', line 49 def debug(*args, logging_context: false, &block) super(*args, *block) unless @suppressions.key?(logging_context) end |
#error(*args, logging_context: false, &block) ⇒ Object
41 42 43 |
# File 'lib/valkyrie/logging.rb', line 41 def error(*args, logging_context: false, &block) super(*args, *block) unless @suppressions.key?(logging_context) end |
#fatal(*args, logging_context: false, &block) ⇒ Object
53 54 55 |
# File 'lib/valkyrie/logging.rb', line 53 def fatal(*args, logging_context: false, &block) super(*args, *block) unless @suppressions.key?(logging_context) end |
#info(*args, logging_context: false, &block) ⇒ Object
45 46 47 |
# File 'lib/valkyrie/logging.rb', line 45 def info(*args, logging_context: false, &block) super(*args, *block) unless @suppressions.key?(logging_context) end |
#suppress_logging_for_contexts!(*logging_contexts) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/valkyrie/logging.rb', line 57 def suppress_logging_for_contexts!(*logging_contexts) Array(logging_contexts).each do |logging_context| @suppressions[logging_context] = true end return unless block_given? yield clear_suppressions!(*logging_contexts) end |
#warn(*args, logging_context: false, &block) ⇒ Object
37 38 39 |
# File 'lib/valkyrie/logging.rb', line 37 def warn(*args, logging_context: false, &block) super(*args, *block) unless @suppressions.key?(logging_context) end |