Sha256: 23366cde31addcc642c2fc748f745a9fc1507fb43582f1c9589d29e153a92909

Contents?: true

Size: 957 Bytes

Versions: 4

Compression:

Stored size: 957 Bytes

Contents

require 'logger'

module Mizuno
    class JavaLogger < Logger
        LEVELS = {
            Logger::DEBUG => Java.org.apache.log4j.Level::DEBUG,
            Logger::INFO => Java.org.apache.log4j.Level::INFO,
            Logger::WARN => Java.org.apache.log4j.Level::WARN,
            Logger::ERROR => Java.org.apache.log4j.Level::ERROR,
            Logger::FATAL => Java.org.apache.log4j.Level::FATAL }

        def initialize
            @log4j = Java.org.apache.log4j.Logger.getLogger('ruby')
        end

        def add(severity, message = nil, progname = nil)
            content = (message or (block_given? and yield) or progname)
            @log4j.log(LEVELS[severity], content)
        end

        def puts(message)
            write(message.to_s)
        end

        def write(message)
            add(INFO, message)
        end

        def flush
            # No-op.
        end

        def close
            # No-op.
        end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mizuno-0.6.1 lib/mizuno/java_logger.rb
mizuno-0.6.0 lib/mizuno/java_logger.rb
mizuno-0.5.1 lib/mizuno/java_logger.rb
mizuno-0.5.0 lib/mizuno/java_logger.rb