Beispiel #1
0
func (e *LoggregatorEmitter) EmitLogMessage(logMessage *events.LogMessage) {
	messages := splitMessage(string(logMessage.GetMessage()))

	for _, message := range messages {
		if isEmpty(message) {
			continue
		}

		if len(message) > MAX_MESSAGE_BYTE_SIZE {
			logMessage.Message = append([]byte(message)[0:TRUNCATED_OFFSET], TRUNCATED_BYTES...)
		} else {
			logMessage.Message = []byte(message)
		}

		logEnvelope, err := e.newLogEnvelope(*logMessage.AppId, logMessage)
		if err != nil {
			e.logger.Errorf("Error creating envelope: %s", err)
			return
		}
		marshalledLogEnvelope, err := proto.Marshal(logEnvelope)
		if err != nil {
			e.logger.Errorf("Error marshalling envelope: %s", err)
			return
		}
		e.LoggregatorClient.Send(marshalledLogEnvelope)
	}
}
Beispiel #2
0
func convertToOldFormat(message *events.LogMessage) *logmessage.LogMessage {
	return &logmessage.LogMessage{
		Message:     message.Message,
		AppId:       message.AppId,
		MessageType: logmessage.LogMessage_MessageType(message.GetMessageType()).Enum(),
		SourceName:  message.SourceType,
		SourceId:    message.SourceInstance,
		Timestamp:   message.Timestamp,
	}
}