Allow logging to be sent to a file

In config.rb, you can write:

logger 'middleman.log'
This commit is contained in:
Ben Hollis 2013-10-19 19:54:57 -07:00
parent e773e8c1a9
commit 12de88e8d7
2 changed files with 8 additions and 6 deletions

View file

@ -1,15 +1,14 @@
# Use the Ruby/Rails logger
require 'active_support/core_ext/logger'
require 'active_support/notifications'
require 'active_support/buffered_logger'
require 'thread'
module Middleman
# The Middleman Logger
class Logger < ::Logger
# Force output to STDOUT
def initialize(log_level=1, is_instrumenting=false, target=STDOUT)
super(STDOUT)
class Logger < ActiveSupport::BufferedLogger
def initialize(log_level=1, is_instrumenting=false, target=$stdout)
super(target)
self.level = log_level
@instrumenting = is_instrumenting

View file

@ -48,6 +48,9 @@ module Middleman
# @return [Middleman::Logger] The logger
def self.logger(*args)
if !@_logger || args.length > 0
if args.length == 1 && (args.first.is_a?(::String) || args.first.respond_to?(:write))
args = [0, false, args.first]
end
@_logger = ::Middleman::Logger.new(*args)
end