Skip to content

log: fix truncating log message to 1024 bytes in 'json' log#10952

Merged
Totktonada merged 1 commit intotarantool:masterfrom
grafin:grafin/gh-10918
Feb 12, 2025
Merged

log: fix truncating log message to 1024 bytes in 'json' log#10952
Totktonada merged 1 commit intotarantool:masterfrom
grafin:grafin/gh-10918

Conversation

@grafin
Copy link
Member

@grafin grafin commented Dec 17, 2024

Before this patch, when log format was set to 'json' and log entry was written with format-string API (require('log').info(<format string>, args...)), in the output the message was truncated to 1024 bytes.

This patch fixes this behavior, and now the message will only be truncated if the full log entry (with all the context) doesn't fit into the 16KiB buffer. The message will be truncated in a way, so all the context is present.

Closes #10918

NO_DOC=bugfix

@grafin grafin force-pushed the grafin/gh-10918 branch 2 times, most recently from 7158df1 to 0441fc1 Compare December 17, 2024 21:23
@grafin grafin added the do not merge Not ready to be merged label Dec 17, 2024
@coveralls
Copy link

coveralls commented Dec 17, 2024

Coverage Status

coverage: 87.429% (+0.03%) from 87.395%
when pulling bd0abf5 on grafin:grafin/gh-10918
into b9c5a1d
on tarantool:master
.

@grafin grafin force-pushed the grafin/gh-10918 branch 6 times, most recently from f859dd7 to 8661f19 Compare December 23, 2024 18:13
@grafin grafin changed the title WIP: Fix truncating log message to 1024 bytes in 'json' log log: fix truncating log message to 1024 bytes in 'json' log Dec 23, 2024
@grafin grafin marked this pull request as ready for review December 23, 2024 18:25
@grafin grafin requested a review from a team as a code owner December 23, 2024 18:25
@grafin grafin requested a review from Totktonada December 23, 2024 18:25
@grafin grafin requested a review from locker December 23, 2024 18:34
@locker locker assigned grafin and unassigned locker Dec 24, 2024
@Totktonada Totktonada removed their assignment Dec 24, 2024
@grafin grafin force-pushed the grafin/gh-10918 branch 2 times, most recently from 71eba06 to 8e7ba90 Compare January 14, 2025 09:12
@grafin grafin requested a review from locker January 14, 2025 09:13
@grafin grafin assigned Totktonada and locker and unassigned grafin Jan 14, 2025
@grafin grafin force-pushed the grafin/gh-10918 branch 2 times, most recently from 4c6a668 to 0760e0a Compare January 30, 2025 09:06
@grafin grafin removed the do not merge Not ready to be merged label Jan 30, 2025
@grafin
Copy link
Member Author

grafin commented Jan 30, 2025

I've added more tap tests (luatest tests will be developed in scope of reworking the logger module task). Current solution works fine for log.<level>("Long message format string...") cases. But it fails to provide a valid JSON output in case of log.<level>({message = "Long message...", ...}), it was broken before, it is still broken, I don't see a reasonably quick solution now.

@grafin grafin added the full-ci Enables all tests for a pull request label Jan 30, 2025
@grafin grafin force-pushed the grafin/gh-10918 branch 10 times, most recently from 6f104a9 to e825d01 Compare February 3, 2025 10:37
@grafin grafin force-pushed the grafin/gh-10918 branch 3 times, most recently from fa04942 to 0146922 Compare February 12, 2025 07:13
Before this patch, when log format was set to 'json' and log entry was
written with format-string API (`require('log').info(<format string>,
args...)`), in the output the message was truncated to 1024 bytes.

This patch fixes this behavior, and now the message will only be
truncated if the full log entry (with all the context) doesn't fit into
the 16KiB buffer. The message will be truncated in a way, so all the
context is present.

Closes tarantool#10918

NO_DOC=bugfix
@Totktonada Totktonada merged commit 6b891b4 into tarantool:master Feb 12, 2025
61 checks passed
@TarantoolBot
Copy link
Collaborator

Backport failed for release/2.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release/2.11
git worktree add -d .worktree/backport/release/2.11/10952 origin/release/2.11
cd .worktree/backport/release/2.11/10952
git switch --create backport/release/2.11/10952
git cherry-pick -x 6b891b4f7648113ed6501d8957f07411d1a33368

@TarantoolBot
Copy link
Collaborator

Successfully created backport PR for release/3.2:

@TarantoolBot
Copy link
Collaborator

Successfully created backport PR for release/3.3:

@TarantoolBot
Copy link
Collaborator

TarantoolBot commented Feb 12, 2025

Backport summary

Footnotes

  1. Conflicts on level_to_string(level) (2.11) vs level_strs[level] (3.x) due to 84a2cf6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.11 Automatically create a 2.11 backport PR backport/3.2 Automatically create a 3.2 backport PR backport/3.3 Automatically create a 3.3 backport PR full-ci Enables all tests for a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the "message" size limit if log_format=json, currently 1Kb

6 participants