Class: BBK::Utils::Logger
- Inherits:
-
Logger
- Object
- Logger
- BBK::Utils::Logger
- Defined in:
- lib/bbk/utils/logger.rb
Constant Summary collapse
- DEFAULT_NAME =
'bbk'
- DEFAULT_LEVEL =
Logger::Severity::DEBUG
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(progname, level, io: STDOUT) ⇒ Logger
constructor
A new instance of Logger.
- #silence(*_args) {|_self| ... } ⇒ Object
Constructor Details
#initialize(progname, level, io: STDOUT) ⇒ Logger
Returns a new instance of Logger.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bbk/utils/logger.rb', line 19 def initialize(progname, level, io: STDOUT) io.sync = true super(io) self.progname = progname if level.is_a?(Integer) self.level = level else level = level.to_s.upcase level = level.present? ? level : 'INFO' self.level = Logger.const_get(level) end self.formatter = LogFormatter.new info "Using LOG_LEVEL=#{level}" end |
Class Method Details
.default ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/bbk/utils/logger.rb', line 40 def self.default unless @default level = ENV.fetch('LOG_LEVEL', DEFAULT_LEVEL) @default = new(DEFAULT_NAME, level) @default.level = level end @default end |
.new(*args, **kwargs) ⇒ Object
14 15 16 17 |
# File 'lib/bbk/utils/logger.rb', line 14 def self.new(*args, **kwargs) instance = super ActiveSupport::TaggedLogging.new(instance) end |
Instance Method Details
#silence(*_args) {|_self| ... } ⇒ Object
36 37 38 |
# File 'lib/bbk/utils/logger.rb', line 36 def silence(*_args) yield self end |