|
Revision 3493, 1.0 kB
(checked in by david, 3 years ago)
|
Added reusable reloading support through the inclusion of the Relodable module that all subclasses of ActiveRecord::Base, ActiveRecord::Observer, ActiveController::Base, and ActionMailer::Base automatically gets [DHH]. Added auto-loading support for classes in modules, so Conductor::Migration will look for conductor/migration.rb and Conductor::Database::Settings will look for conductor/database/settings.rb [Nicholas Seckar]. Refactored extensions to module, class, and object in active support [DHH]
|
| Line | |
|---|
| 1 |
require 'logger' |
|---|
| 2 |
require File.dirname(__FILE__) + '/core_ext/class/attribute_accessors' |
|---|
| 3 |
|
|---|
| 4 |
class Logger |
|---|
| 5 |
cattr_accessor :silencer |
|---|
| 6 |
self.silencer = true |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
def silence(temporary_level = Logger::ERROR) |
|---|
| 10 |
if silencer |
|---|
| 11 |
begin |
|---|
| 12 |
old_logger_level, self.level = level, temporary_level |
|---|
| 13 |
yield self |
|---|
| 14 |
ensure |
|---|
| 15 |
self.level = old_logger_level |
|---|
| 16 |
end |
|---|
| 17 |
else |
|---|
| 18 |
yield self |
|---|
| 19 |
end |
|---|
| 20 |
end |
|---|
| 21 |
|
|---|
| 22 |
private |
|---|
| 23 |
alias old_format_message format_message |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
if method_defined?(:formatter=) |
|---|
| 30 |
def format_message(severity, timestamp, progname, msg) |
|---|
| 31 |
"#{msg}\n" |
|---|
| 32 |
end |
|---|
| 33 |
else |
|---|
| 34 |
def format_message(severity, timestamp, msg, progname) |
|---|
| 35 |
"#{msg}\n" |
|---|
| 36 |
end |
|---|
| 37 |
end |
|---|
| 38 |
end |
|---|