labstack / gommon

Common packages for Go
MIT License
539 stars 101 forks source link

Bad JSON for messages with newlines or quotes #11

Closed sam701 closed 7 years ago

sam701 commented 7 years ago

gommon.log produces erroneous JSON output if the passed message contains newline characters or quotes.

    e.Logger.Info(`hello 
    "world"`)

produces

{"time":"2016-12-18T14:51:44+01:00","level":"INFO","prefix":"echo","file":"main.go","line":"28","message":"hello
    "world""}

This means all panics caught and logged by Echo as JSON are not parsable.

func someHandler(c echo.Context) error {
    panic("abcde")
    return c.String(http.StatusOK, "Hello, World!")
}
vishr commented 7 years ago

Closed in #9