lib/jekyll/assets/logger.rb in jekyll-assets-2.0.0.pre.beta2 vs lib/jekyll/assets/logger.rb in jekyll-assets-2.0.0.pre.beta3
- old
+ new
@@ -1,22 +1,45 @@
module Jekyll
module Assets
+ class Logger
+ Prefix="Jekyll Assets:"
+ def log
+ @_log ||= Jekyll.logger
+ end
- # TODO: jekyll/jekyll@upstream add support for blocks as messages...
- # NOTE: This is a temporary class, until we can go upstream and fix
- # the little known fact that it doesn't accept a block for a message
- # it is passing on. Until then we are holding this.
+ # -----------------------------------------------------------------------
+ # Log Level: 1
+ # -----------------------------------------------------------------------
- class Logger
- def instance
- @logger ||= Jekyll.logger
+ def warn(msg = nil, &block)
+ log.warn(Prefix, (block_given?? block.call : msg))
end
- %W(warn error info debug).each do |k|
- define_method k do |msg = nil, &block|
- instance.send(k, "Jekyll Assets:", block ? block.call : msg)
- end
+ # -----------------------------------------------------------------------
+ # Log Level: 1
+ # -----------------------------------------------------------------------
+
+ def error(msg = nil, &block)
+ log.error(Prefix, (block_given?? block.call : msg))
end
+
+ # -----------------------------------------------------------------------
+ # Log Level: 2
+ # -----------------------------------------------------------------------
+
+ def info(msg = nil, &block)
+ log.info(Prefix, (block_given?? block.call : msg))
+ end
+
+ # -----------------------------------------------------------------------
+ # Log Level: 3
+ # -----------------------------------------------------------------------
+
+ def debug(msg = nil, &block)
+ log.debug(Prefix, (block_given?? block.call : msg))
+ end
+
+ # -----------------------------------------------------------------------
def log_level=(*a)
raise RuntimeError, "Please set log levels on Jekyll.logger"
end
end