Sha256: a6437340fd61e17432f40bd1f5d7e22952843ce07c07900aa2f5acd72b4f860d

Contents?: true

Size: 928 Bytes

Versions: 9

Compression:

Stored size: 928 Bytes

Contents

# encoding: UTF-8

module Rivet

  module Log

    def self.write(level, message)
      @@log ||= SimpleLogger.instance
      @@log.send(level.to_sym) { message }
    end

    def self.info(message)
      write('info', message)
    end

    def self.debug(message)
      write('debug', message)
    end

    def self.fatal(message)
      write('fatal', message)
    end

    def self.warn(message)
      write('warn', message)
    end

    def self.level(level)
      @@log ||= SimpleLogger.instance
      @@log.level = level
    end

    class SimpleLogger < Logger
      include Singleton

      def initialize
        @dev = Logger::LogDevice.new(STDOUT)
        super @dev
        @progname = 'Rivet'
        @formatter = proc do |sev, datetime, name, msg|
          "[#{name}] [#{datetime}] [#{sev}]: #{msg}\n"
        end
        @datetime_format
      end

      def close
        @dev.close
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rivet-3.2.0 lib/rivet/common/logger.rb
rivet-3.1.0 lib/rivet/common/logger.rb
rivet-3.0.5 lib/rivet/common/logger.rb
rivet-3.0.4 lib/rivet/common/logger.rb
rivet-3.0.3 lib/rivet/common/logger.rb
rivet-3.0.2 lib/rivet/common/logger.rb
rivet-3.0.1 lib/rivet/common/logger.rb
rivet-3.0.0 lib/rivet/common/logger.rb
rivet-2.0.0 lib/rivet/logger.rb