mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
3b2121f733
This reverts commit40b2bbeb09, reversing changes made tob4c6cb17cc.
29 lines
779 B
Ruby
29 lines
779 B
Ruby
module OpenProject
|
|
module Logging
|
|
class TeeLogger
|
|
attr_reader :loggers,
|
|
:stdout,
|
|
:file
|
|
|
|
##
|
|
# Initialize a stdout/stderr and file logger
|
|
# with the file logger within <rails root>/log/<filename>
|
|
def initialize(log_name, max_level = ::Logger::DEBUG)
|
|
@stdout = ::ActiveSupport::Logger.new STDOUT
|
|
@file = ::ActiveSupport::Logger.new Rails.root.join("log", "#{File.basename(log_name, '.log')}.log")
|
|
|
|
stdout.level = max_level
|
|
file.level = max_level
|
|
|
|
@loggers = [stdout, file]
|
|
end
|
|
|
|
%w(log debug info warn error fatal unknown).each do |m|
|
|
define_method(m) do |*args|
|
|
@loggers.map { |t| t.send(m, *args) }
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|