class Console::Compatible::Logger
A compatible interface for {::Logger} which can be used with {Console}.
Public Class Methods
Source
# File vendor/bundle/ruby/3.4.0/gems/console-1.30.2/lib/console/compatible/logger.rb, line 52 def initialize(subject, output = Console) super(nil) @progname = subject @logdev = LogDevice.new(subject, output) end
Create a new (compatible) logger.
@parameter subject [String] The subject of the log messages. @parameter output [Console::Interface] The output interface.
Calls superclass method
Logger::new
Public Instance Methods
Source
# File vendor/bundle/ruby/3.4.0/gems/console-1.30.2/lib/console/compatible/logger.rb, line 65 def add(severity, message = nil, progname = nil) severity ||= UNKNOWN if @logdev.nil? or severity < level return true end if progname.nil? progname = @progname end if message.nil? if block_given? message = yield else message = progname progname = @progname end end @logdev.call( progname, message, severity: format_severity(severity) ) return true end
Log a message with the given severity.
@parameter severity [Integer] The severity of the message. @parameter message [String] The message to log. @parameter progname [String] The program name. @returns [Boolean] True if the message was logged.
Source
# File vendor/bundle/ruby/3.4.0/gems/console-1.30.2/lib/console/compatible/logger.rb, line 97 def format_severity(value) super.downcase.to_sym end
Format
the severity.
@parameter value [Integer] The severity value. @returns [Symbol] The formatted severity.
Calls superclass method