コード例 #1
0
	regexSafe := func(matcher string) string {
		return regex.ReplaceAllStringFunc(matcher, func(s string) string {
			return fmt.Sprintf("\\%s", s)
		})
	}

	Context("when the message has lager to chug", func() {
		It("pretties the text for lager message", func() {
			input = []byte(`{"timestamp":"1429296198.620077372","source":"rep","message":"rep.event-consumer.operation-stream.executing-container-operation.succeeded-fetch-container","log_level":1,"data":{"container-guid":"app-9eb203ad-72f3-4f26-6424-48f20dc12298","session":"7.1.10","trace":"trace-me-now"}}`)
			lagerTimestamp := "1429296198.620077372"
			lagerUnixTime, err := strconv.ParseFloat(lagerTimestamp, 64)
			Expect(err).ToNot(HaveOccurred())
			logMessage := buildLogMessage("rep", "cell-77", time.Time{}, input)

			prettyLog := prettify.Prettify(logMessage)

			Expect(prettyLog).ToNot(BeEmpty())

			var outputExpects []string
			outputExpects = append(outputExpects, regexSafe(""))
			outputExpects = append(outputExpects, regexSafe("rep"))
			outputExpects = append(outputExpects, regexSafe("cell-77"))
			outputExpects = append(outputExpects, regexSafe("INFO"))
			outputExpects = append(outputExpects, regexSafe(time.Unix(0, int64(lagerUnixTime*1e9)).Format("01/02 15:04:05.00")))
			outputExpects = append(outputExpects, regexSafe("7.1.10"))
			outputExpects = append(outputExpects, regexSafe("rep.event-consumer.operation-stream.executing-container-operation.succeeded-fetch-container"))
			outputExpects = append(outputExpects, regexSafe("\n"))
			outputExpects = append(outputExpects, regexSafe(`{"container-guid":"app-9eb203ad-72f3-4f26-6424-48f20dc12298"}`))
			outputExpects = append(outputExpects, regexSafe(""))
			regexPattern := strings.Join(outputExpects, ".*")
コード例 #2
0
func (ctlo *ConsoleTailedLogsOutputter) prettyDebugLogCallback(log *events.LogMessage) {
	ctlo.outputChan <- prettify.Prettify(log)
}