lib/glimmer.rb in glimmer-0.5.2 vs lib/glimmer.rb in glimmer-0.5.3
- old
+ new
@@ -40,28 +40,32 @@
@@import_swt_packages
end
# Returns Glimmer logger (standard Ruby logger)
def logger
- unless defined? @@logger
- @@logger = Logger.new(STDOUT).tap {|logger| logger.level = Logger::WARN}
- end
- @@logger
+ # unless defined? @@logger
+ # @@logger = Logger.new(STDOUT).tap {|logger| logger.level = Logger::WARN}
+ # end
+ @@logger if defined? @@logger
end
+
+ def enable_logging
+ @@logger = Logger.new(STDOUT).tap {|logger| logger.level = Logger::WARN}
+ end
end
def method_missing(method_symbol, *args, &block)
# This if statement speeds up Glimmer in girb or whenever directly including on main object
if method_symbol.to_s.match(REGEX_METHODS_EXCLUDED)
raise InvalidKeywordError, "Glimmer excluded keyword: #{method_symbol}"
end
- Glimmer.logger.debug "keyword: " + method_symbol.to_s + " and args: " + args.to_s
+ Glimmer.logger&.debug "keyword: " + method_symbol.to_s + " and args: " + args.to_s
Glimmer::DSL::Engine.interpret(method_symbol, *args, &block)
rescue InvalidKeywordError => e
if !method_symbol.to_s.match(REGEX_METHODS_EXCLUDED)
- Glimmer.logger.error e.message
+ Glimmer.logger&.error e.message
end
- Glimmer.logger.debug "#{e.message}\n#{e.backtrace.join("\n")}"
+ Glimmer.logger&.debug "#{e.message}\n#{e.backtrace.join("\n")}"
super(method_symbol, *args, &block)
end
end
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))