Created
November 19, 2009 20:27
-
-
Save eric/239026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/god/logger.rb b/lib/god/logger.rb | |
| index 7c45679..b08d0f8 100644 | |
| --- a/lib/god/logger.rb | |
| +++ b/lib/god/logger.rb | |
| @@ -58,21 +58,27 @@ module God | |
| def log(watch, level, text) | |
| # initialize watch log if necessary | |
| self.logs[watch.name] ||= Timeline.new(God::LOG_BUFFER_SIZE_DEFAULT) if watch | |
| - | |
| + | |
| # push onto capture and timeline for the given watch | |
| - @templogio.truncate(0) | |
| - @templogio.rewind | |
| - @templog.send(level, text % []) | |
| - @mutex.synchronize do | |
| - @capture.puts(@templogio.string.dup) if @capture | |
| - if watch && (Time.now - @spool < 2) | |
| - self.logs[watch.name] << [Time.now, @templogio.string.dup] | |
| + if @capture || (watch && (Time.now - @spool < 2)) | |
| + @mutex.synchronize do | |
| + @templogio.truncate(0) | |
| + @templogio.rewind | |
| + @templog.send(level, text % []) | |
| + | |
| + message = @templogio.string.dup | |
| + | |
| + if @capture | |
| + @capture.puts(message) | |
| + else | |
| + self.logs[watch.name] << [Time.now, message] | |
| + end | |
| end | |
| end | |
| - | |
| + | |
| # send to regular logger | |
| self.send(level, text % []) | |
| - | |
| + | |
| # send to syslog | |
| Syslog.send(SYSLOG_EQUIVALENTS[level], text) if Logger.syslog | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment