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.3.13 lib/ufo/logger.rb
ufo-6.3.12 lib/ufo/logger.rb
ufo-6.3.11 lib/ufo/logger.rb
ufo-6.3.10 lib/ufo/logger.rb
ufo-6.3.9 lib/ufo/logger.rb
ufo-6.3.8 lib/ufo/logger.rb
ufo-6.3.7 lib/ufo/logger.rb
ufo-6.3.6 lib/ufo/logger.rb
ufo-6.3.5 lib/ufo/logger.rb
ufo-6.3.4 lib/ufo/logger.rb
ufo-6.3.3 lib/ufo/logger.rb
ufo-6.3.2 lib/ufo/logger.rb
ufo-6.3.1 lib/ufo/logger.rb
ufo-6.3.0 lib/ufo/logger.rb
ufo-6.2.5 lib/ufo/logger.rb
ufo-6.2.4 lib/ufo/logger.rb
ufo-6.2.3 lib/ufo/logger.rb
ufo-6.2.2 lib/ufo/logger.rb
ufo-6.2.1 lib/ufo/logger.rb
ufo-6.2.0 lib/ufo/logger.rb