From babbbef5f54dccc8f083d93bcae4b50a0d580d88 Mon Sep 17 00:00:00 2001 From: Khushi Agrawal Date: Fri, 13 Feb 2026 10:53:57 +0000 Subject: [PATCH 1/3] updating writerSegment function to handle multi-line commands --- pkg/shell/writer.go | 12 +++++++++--- pkg/shell/writer_test.go | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/shell/writer.go b/pkg/shell/writer.go index ceaa565f8a..cbf45bfb2b 100644 --- a/pkg/shell/writer.go +++ b/pkg/shell/writer.go @@ -66,9 +66,15 @@ func (w *timestampWriter) Write(p []byte) (n int, err error) { func (w *timestampWriter) writeSegment(buf *bytes.Buffer, p []byte) { if w.startOfLine { - ts := time.Now().UTC().Format(time.RFC3339) - coloredTs := logging.TsColor.Sprint(ts) - buf.WriteString(coloredTs + " ") + if len(p) > 0 { + firstChar := p[0] + // Avoid printing timestamp if the segment starts with an indentation or newline + if firstChar != ' ' && firstChar != '\t' && firstChar != '\n' { + ts := time.Now().UTC().Format(time.RFC3339) + coloredTs := logging.TsColor.Sprint(ts) + buf.WriteString(coloredTs + " ") + } + } } buf.Write(p) } diff --git a/pkg/shell/writer_test.go b/pkg/shell/writer_test.go index b49897791a..96ec88d452 100644 --- a/pkg/shell/writer_test.go +++ b/pkg/shell/writer_test.go @@ -29,6 +29,8 @@ func (s *MySuite) TestTimestampWriter(c *C) { testCases := []string{ "line 1\n", + " indented non-timestamped line\n", + "\n", // blank line "line 2 start...", "...line 2 end\n", "line 3", From 95ae74877d1ee117480f5c731815d0127a27cb8f Mon Sep 17 00:00:00 2001 From: Khushi Agrawal Date: Tue, 17 Feb 2026 12:56:00 +0000 Subject: [PATCH 2/3] Updating write method to handle deployment failure logs --- pkg/shell/writer.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/shell/writer.go b/pkg/shell/writer.go index cbf45bfb2b..1eb61994bd 100644 --- a/pkg/shell/writer.go +++ b/pkg/shell/writer.go @@ -59,17 +59,24 @@ func (w *timestampWriter) Write(p []byte) (n int, err error) { w.startOfLine = false } - // Single atomic write to the underlying writer - nWritten, err := w.writer.Write(buf.Bytes()) - return nWritten, err -} + // Perform the actual write + _, err = w.writer.Write(buf.Bytes()) + + if err != nil { + // If an error occurred, we return 0 bytes of 'p' were written. + // This satisfies the "n < len(p)" rule for errors. + return 0, err + } + return len(p), nil +} func (w *timestampWriter) writeSegment(buf *bytes.Buffer, p []byte) { if w.startOfLine { if len(p) > 0 { - firstChar := p[0] - // Avoid printing timestamp if the segment starts with an indentation or newline - if firstChar != ' ' && firstChar != '\t' && firstChar != '\n' { + switch p[0] { + case ' ', '\t', '\n': + // Do not add timestamp for indented or empty lines. + default: ts := time.Now().UTC().Format(time.RFC3339) coloredTs := logging.TsColor.Sprint(ts) buf.WriteString(coloredTs + " ") From 8542155cb5d55ca08125079c0e19707d212b6103 Mon Sep 17 00:00:00 2001 From: Khushi Agrawal Date: Tue, 17 Feb 2026 15:33:16 +0000 Subject: [PATCH 3/3] removing redundant prefixes --- pkg/logging/logging.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/logging/logging.go b/pkg/logging/logging.go index 4fa3e9082d..04551fabd0 100644 --- a/pkg/logging/logging.go +++ b/pkg/logging/logging.go @@ -52,12 +52,12 @@ func Info(f string, a ...any) { // Error prints info to stderr but does not end the program func Error(f string, a ...any) { msg := fmt.Sprintf(f, a...) - errorlog.Printf("%s ERROR: %s", formatTs(), msg) + errorlog.Printf("%s: %s", formatTs(), msg) } // Fatal prints info to stderr and ends the program func Fatal(f string, a ...any) { msg := fmt.Sprintf(f, a...) - fatallog.Printf("%s FATAL: %s", formatTs(), msg) + fatallog.Printf("%s: %s", formatTs(), msg) Exit(1) }