本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.LogMessage.GetMessage方法的典型用法代码示例。如果您正苦于以下问题:Golang LogMessage.GetMessage方法的具体用法?Golang LogMessage.GetMessage怎么用?Golang LogMessage.GetMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/sonde-go/events.LogMessage
的用法示例。
在下文中一共展示了LogMessage.GetMessage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: EmitLogMessage
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)
}
}
示例2: simpleLogMessageOutput
func simpleLogMessageOutput(logMsg *events.LogMessage) (msgText string) {
msgText = string(logMsg.GetMessage())
reg, err := regexp.Compile("[\n\r]+$")
if err != nil {
return
}
msgText = reg.ReplaceAllString(msgText, "")
return
}
示例3: ExtractNoaaLogContent
func ExtractNoaaLogContent(logMsg *events.LogMessage, logHeader string) (logContent string) {
msgText := string(logMsg.GetMessage())
msgText = newLinesPattern.ReplaceAllString(msgText, "")
msgLines := strings.Split(msgText, "\n")
padding := strings.Repeat(" ", utf8.RuneCountInString(logHeader))
coloringFunc := terminal.LogStdoutColor
logType := "OUT"
if logMsg.GetMessageType() == events.LogMessage_ERR {
coloringFunc = terminal.LogStderrColor
logType = "ERR"
}
logContent = fmt.Sprintf("%s %s", logType, msgLines[0])
for _, msgLine := range msgLines[1:] {
logContent = fmt.Sprintf("%s\n%s%s", logContent, padding, msgLine)
}
logContent = coloringFunc(logContent)
return
}
示例4: ChugLogMessage
func ChugLogMessage(logMessage *events.LogMessage) Entry {
entry := Entry{
IsLager: false,
LogMessage: logMessage,
Raw: logMessage.GetMessage(),
}
rawString := string(entry.Raw)
idx := strings.Index(rawString, "{")
if idx == -1 {
return entry
}
var lagerLog lager.LogFormat
decoder := json.NewDecoder(strings.NewReader(rawString[idx:]))
err := decoder.Decode(&lagerLog)
if err != nil {
return entry
}
entry.Log, entry.IsLager = convertLagerLog(lagerLog)
return entry
}
示例5: getMsgString
func getMsgString(message *events.LogMessage) string {
return string(message.GetMessage())
}
示例6: sendLogMessage
func (s *SyslogSink) sendLogMessage(logMessage *events.LogMessage) error {
_, err := s.syslogWriter.Write(messagePriorityValue(logMessage), logMessage.GetMessage(), logMessage.GetSourceType(), logMessage.GetSourceInstance(), *logMessage.Timestamp)
return err
}
示例7:
logMessages, errors = cnsmr.TailingLogsWithoutReconnect(appGuid, authToken)
})
AfterEach(func() {
cnsmr.Close()
Eventually(logMessages).Should(BeClosed())
})
Context("when there is no TLS Config or consumerProxyFunc setting", func() {
Context("when the connection can be established", func() {
It("returns a read only LogMessage chan and error chan", func() {
fakeHandler.InputChan <- marshalMessage(createMessage("hello", 0))
var message *events.LogMessage
Eventually(logMessages).Should(Receive(&message))
Expect(message.GetMessage()).To(Equal([]byte("hello")))
Consistently(errors).ShouldNot(Receive())
})
It("receives messages on the incoming channel", func(done Done) {
fakeHandler.InputChan <- marshalMessage(createMessage("hello", 0))
message := <-logMessages
Expect(message.GetMessage()).To(Equal([]byte("hello")))
fakeHandler.Close()
close(done)
})
It("does not include metrics", func(done Done) {
示例8: rawDebugLogCallback
func (ctlo *ConsoleTailedLogsOutputter) rawDebugLogCallback(log *events.LogMessage) {
timeString := time.Unix(0, log.GetTimestamp()).Format("01/02 15:04:05.00")
logOutput := fmt.Sprintf("%s [%s|%s] %s", timeString, log.GetSourceType(), log.GetSourceInstance(), log.GetMessage())
ctlo.outputChan <- logOutput
}