Module: AppLogger
- Defined in:
- lib/app_logger.rb,
lib/app_logger/version.rb,
lib/app_logger/middleware.rb,
lib/app_logger/formatter/aws.rb,
lib/app_logger/formatter/json.rb
Defined Under Namespace
Modules: Formatter Classes: Middleware
Constant Summary collapse
- VERSION =
"0.0.4"
Class Method Summary collapse
- .console_logger ⇒ Object
- .new_force_formatted_logger(logdev, level: nil, formatter: nil, console: false, severity: Logger::UNKNOWN) ⇒ Object
- .new_logger(logdev, level: nil, formatter: nil, console: false) ⇒ Object
Class Method Details
.console_logger ⇒ Object
31 32 33 |
# File 'lib/app_logger.rb', line 31 def console_logger @@console_logger ||= ActiveSupport::Logger.new(STDOUT) end |
.new_force_formatted_logger(logdev, level: nil, formatter: nil, console: false, severity: Logger::UNKNOWN) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/app_logger.rb', line 16 def new_force_formatted_logger(logdev, level: nil, formatter: nil, console: false, severity: Logger::UNKNOWN) logger = new_logger(logdev, level: level, formatter: formatter, console: console) logger.instance_variable_set(:@_severity, severity) logger.instance_eval do |obj| class << self define_method :<< do |msg| return true if @logdev.nil? or @_severity < @level @logdev.write((format_severity(@_severity), Time.now, @progname, msg)) true end end end logger end |
.new_logger(logdev, level: nil, formatter: nil, console: false) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/app_logger.rb', line 8 def new_logger(logdev, level: nil, formatter: nil, console: false) logger = ActiveSupport::Logger.new(logdev) logger.level = level if level logger.formatter = formatter if formatter logger.extend ActiveSupport::Logger.broadcast(console_logger) if console logger end |