Class: Quonfig::InternalLogger
- Inherits:
-
Object
- Object
- Quonfig::InternalLogger
- Defined in:
- lib/quonfig/internal_logger.rb
Overview
Internal logger for the Quonfig SDK Uses SemanticLogger if available, falls back to stdlib Logger
Class Method Summary collapse
-
.using_quonfig_log_filter! ⇒ Object
Our client outputs debug logging, but if you aren’t using Quonfig logging this could be too chatty.
Instance Method Summary collapse
- #debug(message = nil, &block) ⇒ Object
- #error(message = nil, &block) ⇒ Object
- #fatal(message = nil, &block) ⇒ Object
- #info(message = nil, &block) ⇒ Object
-
#initialize(klass) ⇒ InternalLogger
constructor
A new instance of InternalLogger.
- #level ⇒ Object
- #level=(new_level) ⇒ Object
-
#trace(message = nil, &block) ⇒ Object
Log methods.
- #warn(message = nil, &block) ⇒ Object
Constructor Details
#initialize(klass) ⇒ InternalLogger
Returns a new instance of InternalLogger.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/quonfig/internal_logger.rb', line 7 def initialize(klass) @klass = klass @level_sym = nil # Track the symbol level for consistency if defined?(SemanticLogger) @logger = create_semantic_logger @using_semantic = true else @logger = create_stdlib_logger @using_semantic = false end # Track all instances regardless of logger type instances << self end |
Class Method Details
.using_quonfig_log_filter! ⇒ Object
Our client outputs debug logging, but if you aren’t using Quonfig logging this could be too chatty. If you aren’t using the quonfig log filter, only log warn level and above
86 87 88 89 90 |
# File 'lib/quonfig/internal_logger.rb', line 86 def self.using_quonfig_log_filter! @@instances&.each do |logger| logger.level = :trace end end |
Instance Method Details
#debug(message = nil, &block) ⇒ Object
28 29 30 |
# File 'lib/quonfig/internal_logger.rb', line 28 def debug( = nil, &block) (:debug, , &block) end |
#error(message = nil, &block) ⇒ Object
40 41 42 |
# File 'lib/quonfig/internal_logger.rb', line 40 def error( = nil, &block) (:error, , &block) end |
#fatal(message = nil, &block) ⇒ Object
44 45 46 |
# File 'lib/quonfig/internal_logger.rb', line 44 def fatal( = nil, &block) (:fatal, , &block) end |
#info(message = nil, &block) ⇒ Object
32 33 34 |
# File 'lib/quonfig/internal_logger.rb', line 32 def info( = nil, &block) (:info, , &block) end |
#level ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/quonfig/internal_logger.rb', line 48 def level if @using_semantic @logger.level else # Return the symbol level we tracked, or map from Logger constant @level_sym || case @logger.level when Logger::DEBUG then :debug when Logger::INFO then :info when Logger::WARN then :warn when Logger::ERROR then :error when Logger::FATAL then :fatal else :warn end end end |
#level=(new_level) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/quonfig/internal_logger.rb', line 64 def level=(new_level) if @using_semantic @logger.level = new_level else # Track the symbol level for consistency @level_sym = new_level # Map symbol to Logger constant @logger.level = case new_level when :trace, :debug then Logger::DEBUG when :info then Logger::INFO when :warn then Logger::WARN when :error then Logger::ERROR when :fatal then Logger::FATAL else Logger::WARN end end end |
#trace(message = nil, &block) ⇒ Object
Log methods
24 25 26 |
# File 'lib/quonfig/internal_logger.rb', line 24 def trace( = nil, &block) (:trace, , &block) end |
#warn(message = nil, &block) ⇒ Object
36 37 38 |
# File 'lib/quonfig/internal_logger.rb', line 36 def warn( = nil, &block) (:warn, , &block) end |