Sha256: bb6b7219b3508dce4d268e7d8e1a162513330b33ed752884502444b6aa8fbed0
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require "logger" module Timber # Allows us to prefix all logs with [Timber] without having to # rely on external dependencies. This is slightly different # in that we don't want to create an entirely new logger or modify # the logger they pass us. We only want to prefix logs in the context # of this library. class InternalLogger < ::Logger class Formatter < ::Logger::Formatter TAG = "[Timber]" # This method is invoked when a log event occurs def call(_severity, _timestamp, _progname, msg) "#{TAG} #{String === msg ? msg : msg.inspect}\n" end end def initialize(*args) super @formatter = Formatter.new end # This is a convenience method for logging exceptions. Also # allows us to build a notify hook for any exception that happen in # the Timber library. This is extremely important for quality control. def exception(exception) if !exception.is_a?(Exception) raise ArgumentError.new("#exception must take an Exception type") end # TODO: notify us that this exception happened error("#{exception.inspect}: #{exception.backtrace.inspect}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timberio-1.0.0.beta1 | lib/timber/internal_logger.rb |