Skip to content

Commit 1603bac

Browse files
author
Jonathan Chauncey
committed
fix(logger): Split on the double new lines when printing log messages
1 parent c673253 commit 1603bac

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

cmd/apps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func AppLogs(appID string, lines int) error {
168168

169169
// printLogs prints each log line with a color matched to its category.
170170
func printLogs(logs string) error {
171-
for _, log := range strings.Split(logs, "\n") {
171+
for _, log := range strings.Split(logs, "\\n\\n") {
172172
category := "unknown"
173173
parts := strings.Split(strings.Split(log, " -- ")[0], " ")
174174
category = parts[0]

controller/models/apps/apps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func Logs(c *client.Client, appID string, lines int) (string, error) {
108108
}
109109

110110
// We need to trim a few characters off the front and end of the string
111-
return body[3 : len(body)-2], nil
111+
return body[2 : len(body)-1], nil
112112
}
113113

114114
// Run one time command in an app.

controller/models/apps/apps_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,11 @@ func TestAppsLogs(t *testing.T) {
337337
tests := []testExpected{
338338
{
339339
Input: -1,
340-
Expected: "test foo bar",
340+
Expected: "\"test foo bar\"",
341341
},
342342
{
343343
Input: 1,
344-
Expected: "test",
344+
Expected: "\"test\"",
345345
},
346346
}
347347

0 commit comments

Comments
 (0)