lib/slf4r/abstract_logger_facade.rb in slf4r-0.3.0 vs lib/slf4r/abstract_logger_facade.rb in slf4r-0.3.1

- old
+ new

@@ -4,11 +4,11 @@ protected def format(exception) (": #{exception.message}:\n\t#{exception.backtrace.join("\n\t") if exception.backtrace }") if exception end - + def _debug(msg) raise NotImplementedError end def _info(msg) @@ -21,12 +21,16 @@ def _error(msg) raise NotImplementedError end - public + def _fatal(msg) + raise NotImplementedError + end + public + attr_reader :name def initialize(name) @name = name end @@ -34,37 +38,56 @@ def debug? raise NotImplementedError end def debug(msg = nil, exception = nil) - msg, exception = yield if block_given? - _debug("#{msg}#{format(exception)}") + if(debug?) + msg, exception = yield if block_given? + _debug("#{msg}#{format(exception)}") + end end def info? raise NotImplementedError end def info(msg = nil, exception = nil) - msg, exception = yield if block_given? - _info("#{msg}#{format(exception)}") + if(info?) + msg, exception = yield if block_given? + _info("#{msg}#{format(exception)}") + end end def warn? raise NotImplementedError end def warn(msg = nil, exception = nil) - msg, exception = yield if block_given? - _warn("#{msg}#{format(exception)}") + if(warn?) + msg, exception = yield if block_given? + _warn("#{msg}#{format(exception)}") + end end def error? raise NotImplementedError end def error(msg = nil, exception = nil) - msg, exception = yield if block_given? - _error("#{msg}#{format(exception)}") + if(error?) + msg, exception = yield if block_given? + _error("#{msg}#{format(exception)}") + end + end + + def fatal? + raise NotImplementedError + end + + def fatal(msg = nil, exception = nil) + if(fatal?) + msg, exception = yield if block_given? + _fatal("#{msg}#{format(exception)}") + end end end end