Class: FluentLoggerRails::Logger
- Inherits:
-
ActiveSupport::Logger
- Object
- ActiveSupport::Logger
- FluentLoggerRails::Logger
- Defined in:
- lib/fluent_logger_rails/logger.rb
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil) ⇒ Object
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize(logger, path:, level:) ⇒ Logger
constructor
A new instance of Logger.
- #tagged(*tags) ⇒ Object
Constructor Details
#initialize(logger, path:, level:) ⇒ Logger
Returns a new instance of Logger.
6 7 8 9 10 11 |
# File 'lib/fluent_logger_rails/logger.rb', line 6 def initialize(logger, path:, level:) @level = SEV_LABEL.index(level.to_s.upcase) @path = path @logger = logger after_initialize if respond_to?(:after_initialize) && ActiveSupport::VERSION::MAJOR < 6 end |
Instance Method Details
#add(severity, message = nil, progname = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fluent_logger_rails/logger.rb', line 13 def add(severity, = nil, progname = nil) return true if severity < @level = (block_given? ? yield : progname) if .blank? return true if .blank? = (severity, Time.zone.now, progname, ) @logger.post(@path, ) true end |
#close ⇒ Object
25 26 27 |
# File 'lib/fluent_logger_rails/logger.rb', line 25 def close @logger.close end |
#flush ⇒ Object
35 36 37 38 |
# File 'lib/fluent_logger_rails/logger.rb', line 35 def flush super if defined?(super) end |
#tagged(*tags) ⇒ Object
31 32 33 |
# File 'lib/fluent_logger_rails/logger.rb', line 31 def tagged(*) formatter.tagged(*) { yield self } end |