Sha256: 60d767a54b0d64c9d6e37efd6af0bfa8971d5218418d82796841be18934230f0
Contents?: true
Size: 1.08 KB
Versions: 18
Compression:
Stored size: 1.08 KB
Contents
require 'singleton' require 'logger' unless defined?(Logger) module Wovnrb class WovnLogger include Singleton class << self def error(message) instance.error(message) end end def initialize path = Store.instance.settings['log_path'] if path begin @logger = Logger.new(path) rescue begin @logger = Logger.new('wovn_error.log') @logger.error("Wovn Error: log_path(#{path}) is invalid, please change log_path at config") rescue @logger = $stderr $stderr.puts("Wovn Error: log_path(#{path}) is invalid, please change log_path at config") end end else @logger = $stderr end end def set_logger(logger) [:error].each do |method| raise 'not suite for logger' unless logger.respond_to? method end @logger = logger end def error(message) if @logger == $stderr @logger.puts "Wovnrb Error: #{message}" else @logger.error message end end end end
Version data entries
18 entries across 18 versions & 1 rubygems