func NewMessage(messageString, appId string) *logmessage.Message {
	logMessage := generateLogMessage(messageString, appId, logmessage.LogMessage_OUT, "App", "")

	marshalledLogMessage, _ := proto.Marshal(logMessage)

	return logmessage.NewMessage(logMessage, marshalledLogMessage)
}
예제 #2
0
func NewMessageWithError(messageString, appId string) (*logmessage.Message, error) {
	logMessage := generateLogMessage(messageString, appId, logmessage.LogMessage_OUT, "App", "")

	marshalledLogMessage, err := proto.Marshal(logMessage)

	return logmessage.NewMessage(logMessage, marshalledLogMessage), err
}
func NewErrMessageWithSourceId(t *testing.T, messageString, appId, sourceId string) *logmessage.Message {
	logMessage := generateLogMessage(messageString, appId, logmessage.LogMessage_ERR, "App", sourceId)

	marshalledLogMessage, err := proto.Marshal(logMessage)
	assert.NoError(t, err)

	return logmessage.NewMessage(logMessage, marshalledLogMessage)
}
func NewMessage(t *testing.T, messageString, appId string) *logmessage.Message {
	logMessage := generateLogMessage(messageString, appId, logmessage.LogMessage_OUT, "App", "")

	marshalledLogMessage, err := proto.Marshal(logMessage)
	assert.NoError(t, err)

	return logmessage.NewMessage(logMessage, marshalledLogMessage)
}
func NewMessageWithSyslogDrain(t *testing.T, messageString, appId string, syslogDrains ...string) *logmessage.Message {
	logMessage := generateLogMessage(messageString, appId, logmessage.LogMessage_OUT, "App", "")
	logMessage.DrainUrls = syslogDrains

	marshalledLogMessage, err := proto.Marshal(logMessage)
	assert.NoError(t, err)

	return logmessage.NewMessage(logMessage, marshalledLogMessage)
}
예제 #6
0
func NewMessage(messageString, appId string) *logmessage.Message {
	logMessage := generateLogMessage(messageString, appId, logmessage.LogMessage_OUT, "App", "")

	marshalledLogMessage, err := proto.Marshal(logMessage)
	if err != nil {
		Fail(err.Error())
	}

	return logmessage.NewMessage(logMessage, marshalledLogMessage)
}
예제 #7
0
func (r *truncatingBuffer) Run() {
	for v := range r.inputChannel {
		r.lock.Lock()
		select {
		case r.outputChannel <- v:
		default:
			messageCount := len(r.outputChannel)
			r.outputChannel = make(chan *logmessage.Message, cap(r.outputChannel))
			lm := generateLogMessage(fmt.Sprintf("Log message output too high. We've dropped %d messages", messageCount), v.GetLogMessage().AppId)
			lmBytes, err := proto.Marshal(lm)
			if err != nil {
				r.logger.Error("TB: Output channel too full. And we failed to notify them. Dropping Buffer.")
				continue
			}
			r.outputChannel <- logmessage.NewMessage(lm, lmBytes)
			r.outputChannel <- v
			if r.logger != nil {
				r.logger.Warn("TB: Output channel too full. Dropped Buffer.")
			}
		}
		r.lock.Unlock()
	}
	close(r.outputChannel)
}
func NewMessageFromLogMessage(t *testing.T, logMessage *logmessage.LogMessage) *logmessage.Message {
	marshalledLogMessage, err := proto.Marshal(logMessage)
	assert.NoError(t, err)

	return logmessage.NewMessage(logMessage, marshalledLogMessage)
}