當前位置: 首頁>>代碼示例>>Golang>>正文


Golang events.LogMessage類代碼示例

本文整理匯總了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;未經允許,請勿轉載。