Sha256: 46db7c2444345f28abc42a109edbe8cb8a713447a8e34016f480eff0c9996e51

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

module Timber
  class LogDevice
    NEWLINE = "\n".freeze
    SPLIT_LINES = true

    def write(message)
      return false if ignoring?
      ignore do
        messages(message).each do |message_part|
          log_line = LogLine.new(message_part)
          write_log_line(log_line)
        end
      end
      true
    rescue Exception => e
      Config.logger.exception(e)
      raise e
    end

    private
      def ignore(&block)
        @ignoring = true
        yield
      ensure
        @ignoring = false
      end

      def ignoring?
        @ignoring == true
      end

      def messages(message)
        message.chomp.split(NEWLINE)
      end

      def write_formatted(formatted_message)
        raise NotImplementedError.new
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 lib/timber/log_device.rb