Class: Debugbar::SimpleLogger
- Inherits:
-
Logger
- Object
- Logger
- Debugbar::SimpleLogger
- Defined in:
- lib/debugbar/loggers/simple_logger.rb
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil) ⇒ Object
-
#initialize(min_level = 2) ⇒ SimpleLogger
constructor
A new instance of SimpleLogger.
Constructor Details
#initialize(min_level = 2) ⇒ SimpleLogger
Returns a new instance of SimpleLogger.
3 4 5 |
# File 'lib/debugbar/loggers/simple_logger.rb', line 3 def initialize(min_level= 2) @min_level = min_level end |
Instance Method Details
#add(severity, message = nil, progname = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/debugbar/loggers/simple_logger.rb', line 7 def add(severity, = nil, progname = nil) # We normally rely on the Tracker to know if the current request is set or nil and log an error to STDOUT, # but in this case, it happens so often that the logs are annoying. # In ActiveCable, only the first call goes through the Rake middleware, so every following communication # doesn't go through TrackCurrentRequest, which initializes the request. return if ::::Current.request.nil? return if severity < @min_level if .nil? if block_given? = yield else = progname progname = nil end end ::Tracker.add_log({ time: Time.now.strftime(::TIME_FORMAT), severity: severity, severity_label: SEV_LABEL[severity], message: , progname: progname, }) end |