// Write the supplied message to the kernel.
763941
func (c *Connection) writeMessage(msg []byte) (err error) {
	// Avoid the retry loop in os.File.Write.
	n, err := syscall.Write(int(c.dev.Fd()), msg)
	if err != nil {
		return
	}

	if n != len(msg) {
		err = fmt.Errorf("Wrote %d bytes; expected %d", n, len(msg))
		return
	}

	return
}
90545
func (lw LoggerWriter) Write(p []byte) (n int, err error) {
	if len(p) == 0 {
		return 0, nil
	}
	lw.logger.Printf("%v", string(p))
	return len(p), nil
}
324094
func (w *stdWriter) Write(buf []byte) (n int, err error) {
	if w == nil || w.Writer == nil {
		return 0, errors.New("Writer not instantiated")
	}
	if buf == nil {
		return 0, nil
	}

	header := [stdWriterPrefixLen]byte{stdWriterFdIndex: w.prefix}
	binary.BigEndian.PutUint32(header[stdWriterSizeIndex:], uint32(len(buf)))

	line := append(header[:], buf...)

	n, err = w.Writer.Write(line)
	n -= stdWriterPrefixLen

	if n < 0 {
		n = 0
	}
	return
}
666238
func (s *BytesWriter) Write(buf []byte) (int, error) {
	return s.writer.Write(buf)
}
1342676
func write(c xterm256.Color, l, msg string) {
	label := l
	if terminal.IsTerminal(syscall.Stderr) {
		label = xterm256.Sprint(c, l)
	}

	fmt.Fprintf(os.Stderr, "[%-7s] %s\n", label, msg)
}
158862
func (w *byteBufferWAL) Write(m WALMessage) {
	if w.stopped {
		w.logger.Debug("WAL already stopped. Not writing message", "msg", m)
		return
	}

	if endMsg, ok := m.(EndHeightMessage); ok {
		w.logger.Debug("WAL write end height message", "height", endMsg.Height, "stopHeight", w.heightToStop)
		if endMsg.Height == w.heightToStop {
			w.logger.Debug("Stopping WAL at height", "height", endMsg.Height)
			w.signalWhenStopsTo <- struct{}{}
			w.stopped = true
			return
		}
	}

	w.logger.Debug("WAL Write Message", "msg", m)
	err := w.enc.Encode(&TimedWALMessage{fixedTime, m})
	if err != nil {
		panic(fmt.Sprintf("failed to encode the msg %v", m))
	}
}
628656
func (s *State232) Write(p []byte) (nn int, err error) {
	l := len(p)
	s.clen += l
	s.tail = append(s.tail, p...)
	return l, nil
}
364312
func (w *builtinWriter) write(p syslog.Priority, msg string) (int, error) {
	// ensure it ends in a \n
	nl := ""
	if !strings.HasSuffix(msg, "\n") {
		nl = "\n"
	}

	err := w.conn.writeString(p, w.hostname, w.tag, msg, nl)
	if err != nil {
		return 0, err
	}
	// Note: return the length of the input, not the number of
	// bytes printed by Fprintf, because this must behave like
	// an io.Writer.
	return len(msg), nil
}
683861
func WriteMessage(w io.Writer, msg Message, pver uint32) (int, error) {
	totalBytes := 0

	// Encode the message payload itself into a temporary buffer.
	// TODO(roasbeef): create buffer pool
	var bw bytes.Buffer
	if err := msg.Encode(&bw, pver); err != nil {
		return totalBytes, err
	}
	payload := bw.Bytes()
	lenp := len(payload)

	// Enforce maximum overall message payload.
	if lenp > MaxMessagePayload {
		return totalBytes, fmt.Errorf("message payload is too large - "+
			"encoded %d bytes, but maximum message payload is %d bytes",
			lenp, MaxMessagePayload)
	}

	// Enforce maximum message payload on the message type.
	mpl := msg.MaxPayloadLength(pver)
	if uint32(lenp) > mpl {
		return totalBytes, fmt.Errorf("message payload is too large - "+
			"encoded %d bytes, but maximum message payload of "+
			"type %v is %d bytes", lenp, msg.MsgType(), mpl)
	}

	// With the initial sanity checks complete, we'll now write out the
	// message type itself.
	var mType [2]byte
	binary.BigEndian.PutUint16(mType[:], uint16(msg.MsgType()))
	n, err := w.Write(mType[:])
	totalBytes += n
	if err != nil {
		return totalBytes, err
	}

	// With the message type written, we'll now write out the raw payload
	// itself.
	n, err = w.Write(payload)
	totalBytes += n

	return totalBytes, err
}
1037697
func (w *Writer) Write(p []byte) (int, error) {
	message := string(p)

	packet := NewPacket(message, &Message{message, nil})
	packet.Level = w.Level
	packet.Logger = w.Logger
	w.Client.Capture(packet, nil)

	return len(p), nil
}
20000
func (w *writerWithoutCloseNotify) Write(buf []byte) (int, error) {
	return w.W.Write(buf)
}
677133
func (o testOutput) Write(p []byte) (int, error) {
	msg := strings.TrimSpace(string(p))
	o.Log(msg)
	return len(p), nil
}
1158851
func WriteMessage(w io.Writer, m *Message) error {
	_, err := w.Write(m.raw)
	return err
}
757754
func (s *Session) Write(msg []byte) error {
	if s.closed() {
		return errors.New("session is closed")
	}

	s.writeMessage(&envelope{t: websocket.TextMessage, msg: msg})

	return nil
}
390944
func (r *responseWriter) Write(b []byte) (int, error) {
	if r.buf == nil {
		return 0, ErrReqNotSupp
	}
	if len(b) > r.buf.Cap()-r.buf.Len() {
		return 0, io.ErrShortWrite
	}

	return r.buf.Write(b)
}
710306
func (w *etmWriter) Write(b []byte) (int, error) {
	if err := w.WriteMsg(b); err != nil {
		return 0, err
	}
	return len(b), nil
}
1174932
func (r *Writer) Write(b []byte) (int, error) {
	nl := ""
	if len(b) == 0 || b[len(b)-1] != '\n' {
		nl = "\n"
	}

	r.conn.SetWriteDeadline(time.Now().Add(1 * time.Second))

	_, err := fmt.Fprintf(r.conn, "  %s  %s%s", syslogHeader, b, nl)
	if err != nil {
		return 0, err
	}

	return len(b), nil
}