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

missing newline separator between json log records #30

Open
brooklynbagel opened this issue Jun 1, 2024 · 0 comments · May be fixed by #32
Open

missing newline separator between json log records #30

brooklynbagel opened this issue Jun 1, 2024 · 0 comments · May be fixed by #32

Comments

@brooklynbagel
Copy link

brooklynbagel commented Jun 1, 2024

When using the json_log_layout layout for structured logging, the records are not separated by a newline or any other separator.

tmp_log <- tempfile()

logger <- logger(appenders = file_appender(file = tmp_log, layout = json_log_layout()))

info(logger, "hungry heart")
info(logger, "everybody want to rule the world")
info(logger, "life during wartime")

readLines(tmp_log)
#> Warning in readLines(tmp_log) :
  incomplete final line found on '/var/folders/gk/tqr6bd9x5kg4nx12mzy20cww0000gp/T//RtmpYgWnwC/file50109fcb8dc'
#> [1] "{\"message\":\"hungry heart\",\"level\":\"INFO\",\"time\":\"2024-06-01T18:53:29Z\"}{\"message\":\"everybody want to rule the world\",\"level\":\"INFO\",\"time\":\"2024-06-01T18:53:29Z\"}{\"message\":\"life during wartime\",\"level\":\"INFO\",\"time\":\"2024-06-01T18:53:29Z\"}"

The expected output should look like:

#> [1] "{\"message\":\"hungry heart\",\"level\":\"INFO\",\"time\":\"2024-06-01T18:53:29Z\"}"
#> [2] "{\"message\":\"everybody want to rule the world\",\"level\":\"INFO\",\"time\":\"2024-06-01T18:53:29Z\"}"
#> [3] "{\"message\":\"life during wartime\",\"level\":\"INFO\",\"time\":\"2024-06-01T18:53:29Z\"}"

reprex.qmd.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant