Sha256: 23dc2972bfb988d2cdef8e747b5af5a0031ad47add032850b6c712feb2e083b5

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

module LetsCert
  class Runner

    # Custom logger formatter
    class LoggerFormatter < Logger::Formatter

      # @private log format
      FORMAT = "[%s] %5s: %s\n".freeze

      # @private time format string
      TIME_FORMAT = '%Y-%m-%d %H:%M:%S'.freeze

      # @param [String] severity
      # @param [Datetime] time
      # @param [nil,String] _progname
      # @param [String] msg
      # @return [String]
      def call(severity, time, _progname, msg)
        FORMAT % [format_datetime(time), severity, msg2str(msg)]
      end

      private

      # @private simple datetime formatter
      # @param [DateTime] time
      # @return [String]
      def format_datetime(time)
        time.strftime TIME_FORMAT
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
letscert-0.4.2 lib/letscert/runner/logger_formatter.rb