Permalink
Browse files

Programatically define the log level methods and use the Logger const…

…ants instead (SyslogLogger didnt define them as I expected)
  • Loading branch information...
1 parent 533451a commit 18dbfcb36369ebb800a22325f689ff4cf27ef467 @dhh dhh committed Oct 19, 2011
Showing with 8 additions and 23 deletions.
  1. +8 −23 activesupport/lib/active_support/tagged_logging.rb
@@ -1,3 +1,5 @@
+require 'logger'
+
module ActiveSupport
# Wraps any standard Logger class to provide tagging capabilities. Examples:
#
@@ -27,29 +29,12 @@ def add(severity, message = nil, progname = nil, &block)
@logger.add(severity, "#{tags}#{message}", progname, &block)
end
-
- def fatal(progname = nil, &block)
- add(@logger.class::FATAL, progname, &block)
- end
-
- def error(progname = nil, &block)
- add(@logger.class::ERROR, progname, &block)
- end
-
- def warn(progname = nil, &block)
- add(@logger.class::WARN, progname, &block)
- end
-
- def info(progname = nil, &block)
- add(@logger.class::INFO, progname, &block)
- end
-
- def debug(progname = nil, &block)
- add(@logger.class::DEBUG, progname, &block)
- end
-
- def unknown(progname = nil, &block)
- add(@logger.class::UNKNOWN, progname, &block)
+ %w( fatal error warn info debug unkown ).each do |severity|
+ eval <<-EOM, nil, __FILE__, __LINE__ + 1
+ def #{severity}(progname = nil, &block)
+ add(Logger::#{severity.upcase}, progname, &block)
+ end
+ EOM
end

0 comments on commit 18dbfcb

Please sign in to comment.