本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.LogMessage类的典型用法代码示例。如果您正苦于以下问题:Golang LogMessage类的具体用法?Golang LogMessage怎么用?Golang LogMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LogMessage类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:27,代码来源:emit.go
示例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
}
开发者ID:VStarkov,项目名称:cli,代码行数:9,代码来源:start.go
示例3: messagePriorityValue
func messagePriorityValue(msg *events.LogMessage) int {
switch msg.GetMessageType() {
case events.LogMessage_OUT:
return 14
case events.LogMessage_ERR:
return 11
default:
return -1
}
}
开发者ID:yingkitw,项目名称:loggregator,代码行数:10,代码来源:syslog_sink.go
示例4: convertToOldFormat
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,
}
}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:10,代码来源:emit.go
示例5: 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
}
开发者ID:riccardomc,项目名称:cf-fastpush-plugin,代码行数:22,代码来源:logs.go
示例6: 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
}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:24,代码来源:chug_log_message.go
示例7: getMsgString
func getMsgString(message *events.LogMessage) string {
return string(message.GetMessage())
}
开发者ID:0976254669,项目名称:cli,代码行数:3,代码来源:log_message_queue_noaa_test.go
示例8: 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
}
开发者ID:yingkitw,项目名称:loggregator,代码行数:4,代码来源:syslog_sink.go
示例9:
JustBeforeEach(func() {
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)
})
开发者ID:cloudfoundry,项目名称:v3-cli-plugin,代码行数:30,代码来源:async_test.go
示例10: 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
}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:5,代码来源:console_tailed_logs_outputter.go
注:本文中的github.com/cloudfoundry/sonde-go/events.LogMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论