func (h *MultiLineHandler) process(message *Message) {

	if h.newContentRe.Match(message.Content) {
		h.countInfo.Add(1)
		// the current line is part of a new message,
		// send the buffer
		h.sendBuffer()
	}

	isTruncated := h.shouldTruncate
	h.shouldTruncate = false

	// track the raw data length and the timestamp so that the agent tails
	// from the right place at restart
	h.linesLen += message.RawDataLen
	h.timestamp = message.Timestamp
	h.status = message.Status

	if h.buffer.Len() > 0 {
		// the buffer already contains some data which means that
		// the current line is not the first line of the message
		h.buffer.Write(escapedLineFeed)
	}

	if isTruncated {
		// the previous line has been truncated because it was too long,
		// the new line is just a remainder,
		// adding the truncated flag at the beginning of the content
		h.buffer.Write(truncatedFlag)
	}

	h.buffer.Write(message.Content)

	if h.buffer.Len() >= h.lineLimit {
		// the multiline message is too long, it needs to be cut off and send,
		// adding the truncated flag the end of the content
		h.buffer.Write(truncatedFlag)
		h.sendBuffer()
		h.shouldTruncate = true
	}
}
// process aggregates multiple lines to form a full multiline message,
// it stops when a line matches with the new content regular expression.
// It also makes sure that the content will never exceed the limit
// and that the length of the lines is properly tracked
// so that the agent restarts tailing from the right place.
process aggregates multiple lines to form a full multiline message,
it stops when a line matches with the new content regular expression.
It also makes sure that the content will never exceed the limit
and that the length of the lines is properly tracked
so that the agent restarts tailing from the right place.
// process aggregates multiple lines to form a full multiline message // it stops when a line matches with the new content regular expression . // It also makes sure that the content will never exceed the limit // and that the length of the lines is properly tracked // so that the agent restarts tailing from the right place .
func (h *MultiLineHandler) process(message *Message) {
	if h.newContentRe.Match(message.Content) {
		h.countInfo.Add(1)
		h.sendBuffer()
	}
	isTruncated := h.shouldTruncate
	h.shouldTruncate = false
	h.linesLen += message.RawDataLen
	h.timestamp = message.Timestamp
	h.status = message.Status
	if h.buffer.Len() > 0 {
		h.buffer.Write(escapedLineFeed)
	}
	if isTruncated {
		h.buffer.Write(truncatedFlag)
	}
	h.buffer.Write(message.Content)
	if h.buffer.Len() >= h.lineLimit {
		h.buffer.Write(truncatedFlag)
		h.sendBuffer()
		h.shouldTruncate = true
	}
}
func ( h * MultiLineHandler ) process ( message * Message ) { if h . newContentRe . Match ( message . Content ) { h . countInfo . Add ( 1 ) h . sendBuffer ( ) } isTruncated := h . shouldTruncate h . shouldTruncate = false h . linesLen += message . RawDataLen h . timestamp = message . Timestamp h . status = message . Status if h . buffer . Len ( ) > 0 { h . buffer . Write ( escapedLineFeed ) } if isTruncated { h . buffer . Write ( truncatedFlag ) } h . buffer . Write ( message . Content ) if h . buffer . Len ( ) >= h . lineLimit { h . buffer . Write ( truncatedFlag ) h . sendBuffer ( ) h . shouldTruncate = true } }
process aggregates multiple lines to form a full multiline message,
it stops when a line matches with the new content regular expression.
process aggregates multiple lines to form a full multiline message it stops when a line matches with the new content regular expression .
// the current line is part of a new message, // send the buffer // track the raw data length and the timestamp so that the agent tails // from the right place at restart // the buffer already contains some data which means that // the current line is not the first line of the message // the previous line has been truncated because it was too long, // the new line is just a remainder, // adding the truncated flag at the beginning of the content // the multiline message is too long, it needs to be cut off and send, // adding the truncated flag the end of the content