Created
May 2, 2014 14:03
-
-
Save y13i/fdb17086f4eddaf5386e to your computer and use it in GitHub Desktop.
標準出力しつつログファイルにも出力する
This file contains 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
require "logger" | |
class PLogger | |
def initialize *args | |
@stdout = Logger.new STDOUT | |
@log = Logger.new *args | |
end | |
%w(debug info warn error fatal).each do |level| | |
define_method(level) do |*args| | |
[@stdout, @log].all? do |output| | |
output.send level, *args | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment