lib/xi/logger.rb in xi-lang-0.1.5 vs lib/xi/logger.rb in xi-lang-0.1.6

- old
+ new

@@ -1,25 +1,28 @@ require 'tmpdir' require 'logger' +require 'xi/error_log' -module Xi::Logger - LOG_FILE = File.join(Dir.tmpdir, 'xi.log') +module Xi + module Logger + LOG_FILE = File.join(Dir.tmpdir, 'xi.log') - def logger - @@logger ||= begin - logger = ::Logger.new(LOG_FILE) - logger.formatter = proc do |severity, datetime, progname, msg| - "[#{datetime.strftime("%F %T %L")}] #{msg}\n" + def logger + @@logger ||= begin + logger = ::Logger.new(LOG_FILE) + logger.formatter = proc do |severity, datetime, progname, msg| + "[#{datetime.strftime("%F %T %L")}] #{msg}\n" + end + logger end - logger end - end - def debug(*args) - logger.debug(args.map(&:to_s).join(' '.freeze)) - end + def debug(*args) + logger.debug(args.map(&:to_s).join(' '.freeze)) + end - def error(error) - logger.error("#{error}:\n#{error.backtrace.join("\n".freeze)}") - ErrorLog.instance << error.to_s + def error(error) + logger.error("#{error}:\n#{error.backtrace.join("\n".freeze)}") + ErrorLog.instance << error.to_s + end end end