// Write implements io.Writer interface to that the standard logger uses.
196058
func (cl *CoLog) Write(p []byte) (n int, err error) {
	cl.mu.Lock()
	defer func() {
		cl.mu.Unlock()
		if r := recover(); r != nil {
			err = fmt.Errorf("error: colog: recovered panic %v\n", r)
			fmt.Fprintln(os.Stderr, err.Error())
		}
	}()

	e := cl.parse(p)
	cl.extractFields(e)
	cl.fireHooks(e)

	if e.Level != unknown && e.Level < cl.minLevel {
		return 0, nil
	}

	if e.Level == unknown && cl.defaultLevel < cl.minLevel {
		return 0, nil
	}

	if cl.formatter == nil {
		err = errors.New("error: colog: missing formatter")
		fmt.Fprintln(os.Stderr, err.Error())
		return 0, err
	}

	fp, err := cl.formatter.Format(e)
	if err != nil {
		fmt.Fprintf(os.Stderr, "error: colog: failed to format entry: %v\n", err)
		return 0, err
	}

	n, err = cl.out.Write(fp)
	if err != nil {
		return n, err
	}

	return len(p), nil
}
30601
func (g *Generator) Write(output string) {
	if err := ioutil.WriteFile(output, g.buf.Bytes(), 0644); err != nil {
		log.Fatalln(err)
	}
}
434541
func (s *Stream) Write(p []byte) (int, error) {
	n, err := s.stream.Write(p)
	// TODO: push this down to a lower level for better accuracy.
	if s.conn.swarm.bwc != nil {
		s.conn.swarm.bwc.LogSentMessage(int64(n))
		s.conn.swarm.bwc.LogSentMessageStream(int64(n), s.Protocol(), s.Conn().RemotePeer())
	}
	return n, err
}
922183
func (l *Logger) Writer(level LogLevel) io.Writer {
	return &writer{l: l, level: level}
}
880351
func (w LogWriter) Write(bytes []byte) (int, error) {
	if len(bytes) > 0 {
		return fmt.Fprint(Output, Yellow.Regular("["), time.Now().Format("15:04:05"), Yellow.Regular("]"), string(bytes))
	}
	return 0, nil
}
1121039
func (w *Writer) Write(buf []byte) (int, error) {
	return w.Writer.Write(buf)
}
923594
func (l *Logger) Write(p []byte) (wLen int, err error) {
	var write = func(w io.Writer, isStdFile bool) {
		x := p
		if !isStdFile && l.flags&LnoFileAnsi != 0 {
			// TODO: If Lcolor is used, then no coloring should
			// have to be stripped. Inefficient.
			x = stripAnsiByte(x)
		}
		wLen, err = w.Write(x)
		if wLen != len(p) {
			err = io.ErrShortWrite
		}
	}
	for _, w := range l.streams {
		wIface := reflect.ValueOf(w).Interface()
		switch wType := wIface.(type) {
		case *os.File:
			if wType == os.Stdout || wType == os.Stderr {
				write(w, true)
				continue
			}
			write(w, false)
		default:
			write(w, false)
		}
	}
	return
}
760422
func (w StdlibWriter) Write(p []byte) (int, error) {
	log.Print(strings.TrimSpace(string(p)))
	return len(p), nil
}
468610
func (w *Writer) Write(iw io.Writer, b *logpb.ButlerLogBundle) error {
	return w.WriteWith(recordio.NewWriter(iw), b)
}
190740
func (g Generator) Write(wr io.Writer) error {
	var buf bytes.Buffer
	if err := g.mockTmpl.Execute(&buf, g); err != nil {
		return err
	}
	err := cleanimports.Clean(wr, buf.Bytes())
	if err != nil {
		err = GenerationError{
			Err:  err,
			Code: buf.Bytes(),
		}
	}
	return err
}
463352
func (w *LoggoWriter) Write(p []byte) (int, error) {
	w.Logger.Logf(w.Level, "%s", p[:len(p)-1]) // omit trailing newline
	return len(p), nil
}
233956
func (w *Writer) Write(p []byte) (n int, err error) {
	return w.buf.Write(p)
}
1303079
func (w *Writer) Write(p []byte) (int, error) {
	w.Lock()
	defer w.Unlock()
	return w.w.Write(p)
}
653528
func (w *Writer) Write(b []byte) (int, error) {
	if w.priority > LOG_DEBUG || w.priority < LOG_EMERG {
		return 0, errors.New("log/syslog: invalid priority")
	}
	return w.conn.writeBytes(w.priority, w.prefix, b)
}
385024
func (w *wrapper) Write(b []byte) (int, error) {
	n, err := w.ResponseWriter.Write(b)
	w.written += n
	return n, err
}
846735
func (l *LogFile) Write(b []byte) (n int, err error) {
	// Filter out log entries that do not match log level criteria
	if !l.logFilter.Check(b) {
		return 0, nil
	}

	l.acquire.Lock()
	defer l.acquire.Unlock()
	//Create a new file if we have no file to write to
	if l.FileInfo == nil {
		if err := l.openNew(); err != nil {
			return 0, err
		}
	}
	// Check for the last contact and rotate if necessary
	if err := l.rotate(); err != nil {
		return 0, err
	}
	l.BytesWritten += int64(len(b))
	return l.FileInfo.Write(b)
}
217939
func (wr *Writer) Write(p []byte) (n int, err error) {
	wr.bf.Write(p)
	if bytes.HasSuffix(p, []byte(wr.lastElement)) {
		return wr.writer.Write([]byte(Format(wr.bf.String()) + "\n"))
	}
	return 0, nil
}