Wraps any standard Logger class to provide tagging capabilities. Examples:
Logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) Logger.tagged("BCX") { Logger.info "Stuff" } # Logs "[BCX] Stuff" Logger.tagged("BCX", "Jason") { Logger.info "Stuff" } # Logs "[BCX] [Jason] Stuff" Logger.tagged("BCX") { Logger.tagged("Jason") { Logger.info "Stuff" } } # Logs "[BCX] [Jason] Stuff"
This is used by the default Rails.logger as configured by Railties to make it easy to stamp log lines with subdomains, request ids, and anything else to aid debugging of multi-user production applications.
# File lib/active_support/tagged_logging.rb, line 46 46: def add(severity, message = nil, progname = nil, &block) 47: message = (block_given? ? block.call : progname) if message.nil? 48: @logger.add(severity, "#{tags_text}#{message}", progname) 49: end
# File lib/active_support/tagged_logging.rb, line 59 59: def flush 60: clear_tags! 61: @logger.flush if @logger.respond_to?(:flush) 62: end
# File lib/active_support/tagged_logging.rb, line 64 64: def method_missing(method, *args) 65: @logger.send(method, *args) 66: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.