package colors_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/cloudfoundry-incubator/lattice/ltc/terminal/colors" ) var _ = Describe("Colorize", func() { It("colors the text with printf-style syntax", func() { Expect(colors.Colorize("\x1b[98m", "%dxyz%s", 23, "happy")).To(Equal("\x1b[98m23xyzhappy\x1b[0m")) }) It("colors the text without printf-style syntax", func() { Expect(colors.Colorize("\x1b[98m", "happy")).To(Equal("\x1b[98mhappy\x1b[0m")) }) })
prettyLog := prettify.Prettify(logMessage) Expect(prettyLog).ToNot(ContainSubstring("{}")) Expect(prettyLog).ToNot(ContainSubstring("\n")) }) }) Describe("output coloring", func() { It("highlights the source type column with app-specific color", func() { input = []byte(`{"timestamp":"1429296198.620077372","source":"rep","message":"rep.event-consumer.operation-stream.executing-container-operation.succeeded-fetch-container","log_level":1,"data":{}}`) logMessage := buildLogMessage("rep", "cell-77", time.Time{}, input) prettyLog := prettify.Prettify(logMessage) Expect(prettyLog).To(MatchRegexp(strings.Replace(colors.Colorize("\x1b[34m", "rep"), "[", `\[`, -1))) }) Context("when the source type is unknown", func() { It("highlights the source type column with no color", func() { input = []byte(`{"timestamp":"1429296198.620077372","source":"happyjoy","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"}}`) logMessage := buildLogMessage("happyjoy", "", time.Time{}, input) prettyLog := prettify.Prettify(logMessage) Expect(prettyLog).To(MatchRegexp(strings.Replace(colors.Colorize("\x1b[0m", "happyjoy"), "[", `\[`, -1))) }) }) Context("for the various log levels", func() {