Sha256: 98bfe8b82a138105d9f9f222e1a9aae8ae4082916983ffe820f6ad30ab18308a

Contents?: true

Size: 783 Bytes

Versions: 36

Compression:

Stored size: 783 Bytes

Contents

require 'logger'

module Ufo
  class Logger < ::Logger
    def initialize(*args)
      super
      self.formatter = Formatter.new
      self.level = ENV['UFO_LOG_LEVEL'] || :info # note: only respected when config.logger not set in config/app.rb
    end

    def format_message(severity, datetime, progname, msg)
      line = if @logdev.dev == $stdout || @logdev.dev == $stderr || @logdev.dev.is_a?(StringIO)
        msg # super simple format if stdout
      else
        super # use the configured formatter
      end
      line =~ /\n$/ ? line : "#{line}\n"
    end

    # Used to allow output to always go to stdout
    def stdout(msg, newline: true)
      if newline
        puts msg
      else
        print msg
      end
    end

    public :print
    public :printf
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
ufo-6.1.5 lib/ufo/logger.rb
ufo-6.1.4 lib/ufo/logger.rb
ufo-6.1.3 lib/ufo/logger.rb
ufo-6.1.2 lib/ufo/logger.rb
ufo-6.1.1 lib/ufo/logger.rb
ufo-6.1.0 lib/ufo/logger.rb
ufo-6.0.9 lib/ufo/logger.rb
ufo-6.0.8 lib/ufo/logger.rb
ufo-6.0.7 lib/ufo/logger.rb
ufo-6.0.6 lib/ufo/logger.rb
ufo-6.0.5 lib/ufo/logger.rb
ufo-6.0.4 lib/ufo/logger.rb
ufo-6.0.3 lib/ufo/logger.rb
ufo-6.0.2 lib/ufo/logger.rb
ufo-6.0.1 lib/ufo/logger.rb
ufo-6.0.0 lib/ufo/logger.rb