def flush
      return self if @buffer.empty?

      ary = nil
      sync {
        ary = @buffer.dup
        @buffer.clear
      }

      if ary.length <= write_size
        str = ary.join
        canonical_write str unless str.empty?
      else
        ary.each_slice(write_size) do |a|
          str = a.join
          canonical_write str unless str.empty?
        end
      end

      self
    end
def flush
      return self if @buffer.empty?

      ary = nil
      sync {
        ary = @buffer.dup
        @buffer.clear
      }

      if ary.length <= write_size
        str = ary.join
        canonical_write str unless str.empty?
      else
        ary.each_slice(write_size) do |a|
          str = a.join
          canonical_write str unless str.empty?
        end
      end

      self
    end
Call `flush` to force an appender to write out any buffered log events.
 Similar to `IO#flush`, so use in a similar fashion.