Sha256: eb40f0e28d5463768065b89331e0e2d3bf30db515d5caff7d0adaf9a67e86bfc

Contents?: true

Size: 867 Bytes

Versions: 3

Compression:

Stored size: 867 Bytes

Contents

module MJ; module Logging;

    #
    # Basic Layout for the logging framework.
    #
    # Will prefix message according to the following list:
    #
    #   WARNING => 'warning: '
    #   ERROR   => 'error: '
    #   REST    => ''
    class BasicLayout < ::Logging::Layout

        def format( event )
          obj = format_obj(event.data)

          return case event.level

          when ::Logging::level_num(:ERROR)
              sprintf("error: %s\n", obj)

          when ::Logging::level_num(:WARN)
              sprintf("warning: %s\n", obj)

          else
              obj + "\n"
          end
        end

    end # class BasicLayout

    class LoggerAdapter

        def initialize( prefix )
            @prefix = prefix.upcase
        end

        def info( string )
            logger.trace( "<#{@prefix}> #{string}" )
        end
    end

end; end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
build-tool-0.3.1 lib/mj/logging.rb
build-tool-0.3 lib/mj/logging.rb
build-tool-0.2 lib/mj/logging.rb