lib/teLogger.rb in teLogger-0.1.0 vs lib/teLogger.rb in teLogger-0.2.0

- old
+ new

@@ -12,10 +12,12 @@ # for classes including the TeLogger module TeLogHelper module ClassMethods # methods called at class level by included class + # However if TeLogHelper is included inside Module1, only Module1 is included in Class1, + # Class1 will not be able to access the class level method here. def teLogger_tag(val) @telTag = val end def teLogger_output(*val) @@ -35,25 +37,40 @@ @telOutput end end end # ClassMethods - + def self.included(klass) klass.extend(ClassMethods) - klass.class_eval <<-END - extend TeLogger::TeLogHelper - END + klass.extend(TeLogHelper) end + #def logOutput=(val) + # @logOut = val + #end + + #def logOutput + # if self.class.respond_to?(:logOutput) + # self.class.logOutput + # else + # @logOut + # end + #end + private def teLogger if @teLogger.nil? if self.class.respond_to?(:logOutput) + intLogger.debug "Class logOutput is #{self.class.logOutput}" @teLogger = Tlogger.new(*self.class.logOutput) - else + elsif self.respond_to?(:logOutput) + intLogger.debug "logOutput is #{logOutput}" @teLogger = Tlogger.new(*logOutput) + else + intLogger.debug "logOutput is not available. Please note TeLogHelper mixin only works properly on directly included class/module. Fall back to console only" + @teLogger = Tlogger.new end if self.respond_to?(:logTag) @teLogger.tag = logTag elsif self.class.respond_to?(:logTag) @@ -61,9 +78,23 @@ end end @teLogger end + + def intLogger + if @intLogger.nil? + intLogOut = ENV['TELOGGER_INTLOG_OUT'] + if intLogOut.nil? or intLogOut.empty? + @intLogger = Tlogger.new + else + intLogOut = [intLogOut] if not intLogOut.is_a?(Array) + @intLogger = Tlogger.new(*intLogOut) + end + end + @intLogger + end + end end