Sha256: 1d4b5df056ab6e0e1bf952ee24871bf177957d10976082ec09c889a526c25398

Contents?: true

Size: 639 Bytes

Versions: 8

Compression:

Stored size: 639 Bytes

Contents

require 'logger'

module Terraspace
  class Logger < ::Logger
    # Only need to override the add method as the other calls all lead to it.
    def add(severity, message = nil, progname = nil)
      # Taken from Logger#add source
      # https://ruby-doc.org/stdlib-2.5.1/libdoc/logger/rdoc/Logger.html#method-i-add
      if message.nil?
        if block_given?
          message = yield
        else
          message = progname
          progname = @progname
        end
      end

      super # original logic
    end

    # plain formatting
    def format_message(severity, timestamp, progname, msg)
      "#{msg}\n"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
terraspace-0.2.4 lib/terraspace/logger.rb
terraspace-0.2.3 lib/terraspace/logger.rb
terraspace-0.2.2 lib/terraspace/logger.rb
terraspace-0.2.1 lib/terraspace/logger.rb
terraspace-0.2.0 lib/terraspace/logger.rb
terraspace-0.1.2 lib/terraspace/logger.rb
terraspace-0.1.1 lib/terraspace/logger.rb
terraspace-0.1.0 lib/terraspace/logger.rb