Module: DRbService::Logging
- Included in:
- DRbService
- Defined in:
- lib/drbservice/utils.rb
Overview
DRbService logging methods and data.
Defined Under Namespace
Modules: ClassMethods Classes: ClassNameProxy
Constant Summary collapse
- LEVEL =
Mapping of symbols to logging levels
{ :debug => Logger::DEBUG, :info => Logger::INFO, :warn => Logger::WARN, :error => Logger::ERROR, :fatal => Logger::FATAL, }
Class Method Summary collapse
-
.included(mod) ⇒ Object
Inclusion callback: Add logging methods and instance variables to the Module
mod.
Instance Method Summary collapse
-
#initialize_copy(original) ⇒ Object
Copy constructor – clear the original’s log proxy.
-
#log ⇒ Object
Return the proxied logger.
-
#log_debug ⇒ Object
Return a proxied “debug” logger that ignores other level specification.
Class Method Details
.included(mod) ⇒ Object
Inclusion callback: Add logging methods and instance variables to the Module mod.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/drbservice/utils.rb', line 319 def self::included( mod ) # Logging class instance variables default_logger = Logger.new( $stderr ) default_logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN formatter = DRbService::LogFormatter.new( default_logger ) default_logger.formatter = formatter mod.instance_variable_set( :@default_logger, default_logger ) mod.instance_variable_set( :@default_log_formatter, formatter ) mod.instance_variable_set( :@logger, default_logger ) # Accessors class << mod include DRbService::Logging::ClassMethods # The log formatter that will be used when the logging subsystem is reset attr_accessor :default_log_formatter # The logger that will be used when the logging subsystem is reset attr_accessor :default_logger # The logger that's currently in effect attr_accessor :logger alias_method :log, :logger alias_method :log=, :logger= end end |
Instance Method Details
#initialize_copy(original) ⇒ Object
Copy constructor – clear the original’s log proxy.
403 404 405 406 |
# File 'lib/drbservice/utils.rb', line 403 def initialize_copy( original ) @log_proxy = @log_debug_proxy = nil super end |
#log ⇒ Object
Return the proxied logger.
410 411 412 |
# File 'lib/drbservice/utils.rb', line 410 def log @log_proxy ||= ClassNameProxy.new( self.class ) end |
#log_debug ⇒ Object
Return a proxied “debug” logger that ignores other level specification.
416 417 418 |
# File 'lib/drbservice/utils.rb', line 416 def log_debug @log_debug_proxy ||= ClassNameProxy.new( self.class, true ) end |