Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture newlines in log stdlib #1041

Merged
merged 1 commit into from Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions log/stdlib.go
Expand Up @@ -131,7 +131,7 @@ const (
logRegexpDate = `(?P<date>[0-9]{4}/[0-9]{2}/[0-9]{2})?[ ]?`
logRegexpTime = `(?P<time>[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?)?[ ]?`
logRegexpFile = `(?P<file>.+?:[0-9]+)?`
logRegexpMsg = `(: )?(?P<msg>.*)`
logRegexpMsg = `(: )?(?P<msg>(?s:.*))`
)

var (
Expand All @@ -145,7 +145,7 @@ func subexps(line []byte) map[string]string {
}
result := map[string]string{}
for i, name := range logRegexp.SubexpNames() {
result[name] = string(m[i])
result[name] = strings.TrimRight(string(m[i]), "\n")
}
return result
}
6 changes: 6 additions & 0 deletions log/stdlib_test.go
Expand Up @@ -130,6 +130,12 @@ func TestStdlibAdapterSubexps(t *testing.T) {
"file": "",
"msg": "hello world",
},
"hello\nworld": {
"date": "",
"time": "",
"file": "",
"msg": "hello\nworld",
},
"2009/01/23: hello world": {
"date": "2009/01/23",
"time": "",
Expand Down