def write( event )
      str = event.instance_of?(::Logging::LogEvent) ?
            layout.format(event) : event.to_s
      return if str.empty?

      if @auto_flushing == 1
        canonical_write(str)
      else
        str = str.force_encoding(encoding) if encoding && str.encoding != encoding
        sync {
          @buffer << str
        }
        flush_now = @buffer.length >= @auto_flushing || immediate?(event)

        if flush_now
          if async?
            @async_flusher.signal(flush_now)
          else
            self.flush
          end
        elsif @async_flusher && flush_period?
          @async_flusher.signal
        end
      end

      self
    end
def write( event )
      str = event.instance_of?(::Logging::LogEvent) ?
            layout.format(event) : event.to_s
      return if str.empty?

      if @auto_flushing == 1
        canonical_write(str)
      else
        str = str.force_encoding(encoding) if encoding && str.encoding != encoding
        sync {
          @buffer << str
        }
        flush_now = @buffer.length >= @auto_flushing || immediate?(event)

        if flush_now
          if async?
            @async_flusher.signal(flush_now)
          else
            self.flush
          end
        elsif @async_flusher && flush_period?
          @async_flusher.signal
        end
      end

      self
    end
call-seq:
    write( event )

 Writes the given `event` to the logging destination. The `event` can
 be either a LogEvent or a String. If a LogEvent, then it will be
 formatted using the layout given to the appender when it was created.

 The `event` will be formatted and then buffered until the
 "auto_flushing" level has been reached. At this time the canonical_write
 method will be used to log all events stored in the buffer.

 Returns this appender instance