func (w *UDPWriter) WriteCustomMessage(m *Message) error {
	w.mu.Lock()
	defer w.mu.Unlock()

	mBytes, err := json.Marshal(m)
	if err != nil {
		return err
	}

	var zBuf bytes.Buffer

	// . If compression settings have changed, a new writer is required.
	if w.zwCompressionType != w.config.CompressionType || w.zwCompressionLevel != w.config.CompressionLevel {
		w.zw = nil
	}

	switch w.config.CompressionType {
	case CompressGzip:
		if w.zw == nil {
			w.zw, err = gzip.NewWriterLevel(&zBuf, w.config.CompressionLevel)
		}
	case CompressZlib:
		if w.zw == nil {
			w.zw, err = zlib.NewWriterLevel(&zBuf, w.config.CompressionLevel)
		}
	case NoCompress:
		w.zw = &bufferedWriter{}
	default:
		panic(fmt.Sprintf("unknown compression type %d",
			w.config.CompressionType))
	}

	if err != nil {
		return err
	}

	w.zw.Reset(&zBuf)

	if _, err = w.zw.Write(mBytes); err != nil {
		return err
	}
	w.zw.Close()

	zBytes := zBuf.Bytes()
	if numChunks(zBytes, w.config.ChunkSize) > 1 {
		return w.writeChunked(zBytes)
	}

	n, err := w.conn.Write(zBytes)
	if err != nil {
		return err
	}
	if n != len(zBytes) {
		return fmt.Errorf("bad write (%d/%d)", n, len(zBytes))
	}

	return nil
}
// WriteCustomMessage sends the specified message to the GELF server
// specified in the call to NewWriter(). It assumes all the fields are
// filled out appropriately. In general, clients will want to use
// Write, rather than WriteMessage.
WriteCustomMessage sends the specified message to the GELF server
specified in the call to NewWriter(). It assumes all the fields are
filled out appropriately. In general, clients will want to use
Write, rather than WriteMessage.
// WriteCustomMessage sends the specified message to the GELF server // specified in the call to NewWriter () . It assumes all the fields are // filled out appropriately . In general clients will want to use // Write rather than WriteMessage .
func (w *UDPWriter) WriteCustomMessage(m *Message) error {
	w.mu.Lock()
	defer w.mu.Unlock()
	mBytes, err := json.Marshal(m)
	if err != nil {
		return err
	}
	var zBuf bytes.Buffer
	if w.zwCompressionType != w.config.CompressionType || w.zwCompressionLevel != w.config.CompressionLevel {
		w.zw = nil
	}
	switch w.config.CompressionType {
	case CompressGzip:
		if w.zw == nil {
			w.zw, err = gzip.NewWriterLevel(&zBuf, w.config.CompressionLevel)
		}
	case CompressZlib:
		if w.zw == nil {
			w.zw, err = zlib.NewWriterLevel(&zBuf, w.config.CompressionLevel)
		}
	case NoCompress:
		w.zw = &bufferedWriter{}
	default:
		panic(fmt.Sprintf("unknown compression type %d",
			w.config.CompressionType))
	}
	if err != nil {
		return err
	}
	w.zw.Reset(&zBuf)
	if _, err = w.zw.Write(mBytes); err != nil {
		return err
	}
	w.zw.Close()
	zBytes := zBuf.Bytes()
	if numChunks(zBytes, w.config.ChunkSize) > 1 {
		return w.writeChunked(zBytes)
	}
	n, err := w.conn.Write(zBytes)
	if err != nil {
		return err
	}
	if n != len(zBytes) {
		return fmt.Errorf("bad write (%d/%d)", n, len(zBytes))
	}
	return nil
}
func ( w * UDPWriter ) WriteCustomMessage ( m * Message ) error { w . mu . Lock ( ) defer w . mu . Unlock ( ) mBytes , err := json . Marshal ( m ) if err != nil { return err } var zBuf bytes . Buffer if w . zwCompressionType != w . config . CompressionType || w . zwCompressionLevel != w . config . CompressionLevel { w . zw = nil } switch w . config . CompressionType { case CompressGzip : if w . zw == nil { w . zw , err = gzip . NewWriterLevel ( & zBuf , w . config . CompressionLevel ) } case CompressZlib : if w . zw == nil { w . zw , err = zlib . NewWriterLevel ( & zBuf , w . config . CompressionLevel ) } case NoCompress : w . zw = & bufferedWriter { } default : panic ( fmt . Sprintf ( " " , w . config . CompressionType ) ) } if err != nil { return err } w . zw . Reset ( & zBuf ) if _ , err = w . zw . Write ( mBytes ) ; err != nil { return err } w . zw . Close ( ) zBytes := zBuf . Bytes ( ) if numChunks ( zBytes , w . config . ChunkSize ) > 1 { return w . writeChunked ( zBytes ) } n , err := w . conn . Write ( zBytes ) if err != nil { return err } if n != len ( zBytes ) { return fmt . Errorf ( " " , n , len ( zBytes ) ) } return nil }
WriteCustomMessage sends the specified message to the GELF server
specified in the call to NewWriter().
WriteCustomMessage sends the specified message to the GELF server specified in the call to NewWriter () .
// . If compression settings have changed, a new writer is required.