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

Log module should escape invalid characters properly in JSON and other supported formats #1192

Closed
nadundesilva opened this issue Mar 31, 2021 · 0 comments · Fixed by ballerina-platform/module-ballerina-log#116
Assignees
Labels
module/log Points/2 Team/DIU Data, IO, and Util packages related issues Type/Bug

Comments

@nadundesilva
Copy link

Description:
Currently, invalid characters in logs are not properly formatted and therefore results in malformed log lines. We need to investigate on the invalid characters in the supported formats and escape them accordingly.

Found the following characters that cause the log lines to be malformed

  • \n
  • "

Steps to reproduce:
Use the following code

import ballerina/log;

public function main() {
    log:printError("Request received from user \"nadun\"");
    log:printError("New line test \n test log end");
}

JSON Log Output:

{"time": "2021-03-31 14:11:09,906", "level": "ERROR", "module": "nadun/test_logs", "message": "Request received from user "nadun""}
{"time": "2021-03-31 14:11:09,931", "level": "ERROR", "module": "nadun/test_logs", "message": "New line test
 test log end"}

Normal Log Output:

time = 2021-03-31 14:12:12,890 level = ERROR module = nadun/test_logs message = "Request received from user "nadun""
time = 2021-03-31 14:12:12,909 level = ERROR module = nadun/test_logs message = "New line test
 test log end

Affected Versions:
Ballerina Swan Lake Alpha 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/log Points/2 Team/DIU Data, IO, and Util packages related issues Type/Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants