Use centralized Logger and add instrument methods

This commit is contained in:
Thomas Reynolds 2012-07-15 11:04:45 -07:00
parent 95339dad23
commit de6d7980ac
15 changed files with 126 additions and 61 deletions

View file

@ -1,3 +1,9 @@
# Our custom logger
require "middleman-core/logger"
# For instrumenting
require "active_support/notifications"
# Using Thor's indifferent hash access
require "thor"
@ -6,6 +12,23 @@ require "pathname"
module Middleman
module Util
# The logger
#
# @return [Middleman::Logger] The logger
def self.logger(*args)
if !@_logger || args.length > 0
@_logger = ::Middleman::Logger.new(*args)
end
@_logger
end
# Facade for ActiveSupport/Notification
def self.instrument(name, payload={}, &block)
name << ".middleman" unless name =~ /\.middleman$/
::ActiveSupport::Notifications.instrument(name, payload, &block)
end
# Recursively convert a normal Hash into a HashWithIndifferentAccess
#