Merge pull request #1053 from bhollis/logging

Allow logging to be sent to a file
This commit is contained in:
Thomas Reynolds 2013-10-21 10:37:02 -07:00
commit 764efe65cd
2 changed files with 8 additions and 6 deletions

View file

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

View file

@ -48,6 +48,9 @@ module Middleman
# @return [Middleman::Logger] The logger # @return [Middleman::Logger] The logger
def self.logger(*args) def self.logger(*args)
if !@_logger || args.length > 0 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) @_logger = ::Middleman::Logger.new(*args)
end end