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

Allow customisable log line length #292

Merged
merged 6 commits into from
May 3, 2018
Merged

Allow customisable log line length #292

merged 6 commits into from
May 3, 2018

Conversation

chrissie-c
Copy link
Contributor

@chrissie-c chrissie-c commented Jan 26, 2018

Allow the logging line length to be changed. Any reasonable length is allowable, the default is 512 as before. Anything more than 512 incurs several mallocs.

Log lines that exceed the length will have ... as the last 3 characters.

@chrissie-c chrissie-c changed the title Logline length Allow customisable log line length Jan 26, 2018
chunk = msg_len_pt + sizeof(uint32_t); /* Reset */

msg_len = qb_vsnprintf_serialize(chunk, QB_LOG_MAX_LEN,
msg_len = qb_vsnprintf_serialize(chunk, max_size,
"Log message too long to be stored in the blackbox. "\
"Maximum is QB_LOG_MAX_LEN" , ap);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing the message indicates me there are likely other issues to be hit,
at least in blackbox context.

lib/log.c Outdated
@@ -1196,6 +1221,9 @@ qb_log_ctl2(int32_t t, enum qb_log_conf c, qb_log_ctl2_arg_t arg_not4directuse)
case QB_LOG_CONF_EXTENDED:
conf[t].extended = arg_i32;
break;
case QB_LOG_CONF_MAX_LINE_LEN:
conf[t].max_line_length = arg_i32;
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No boundary requirement is no-go.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could, e.g., easily overflow the blackbox with a single message like that.

@chrissie-c
Copy link
Contributor Author

TBH I'm tempted to leave the blackbox line length restriction at QB_LOG_MAX_LEN as it's the one place where having log lines can really clog up the system.

Any ideas for a limit for what would be the actual hard limit imposed in qb_log_ctl()? In principle I was hoping to avoid arbitrary limits in there. if you ask for more than is reasonable then you suffer the consequences at malloc() time - same as if you called malloc() yourself. I'm easy on this though, a 64K limit would not be unreasonable I think.

@kgaillot
Copy link
Contributor

Any ideas for a limit for what would be the actual hard limit imposed in qb_log_ctl()? In principle I was hoping to avoid arbitrary limits in there. if you ask for more than is reasonable then you suffer the consequences at malloc() time - same as if you called malloc() yourself. I'm easy on this though, a 64K limit would not be unreasonable I think.

No preference here. I think an upper limit anywhere from 2K to 16K would be reasonable.

@jnpkrn
Copy link
Contributor

jnpkrn commented Jan 30, 2018 via email

@@ -584,6 +584,7 @@ enum qb_log_conf {
QB_LOG_CONF_EXTENDED,
QB_LOG_CONF_IDENT,
QB_LOG_CONF_MAX_LINE_LEN,
QB_LOG_CONF_ELIPSIS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi spelling is "ellipsis"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I knew it looked wrong, but couldn't quite figure out why!

@chrissie-c chrissie-c merged commit 0ec02f9 into ClusterLabs:master May 3, 2018
@jnpkrn
Copy link
Contributor

jnpkrn commented Jan 24, 2019

In retrospect, thanks for sticking with my advice to keep the maximum
limited in a reasonable way (4KiB here), see also glibc's extraneously
imposed allocations:
https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01758.html
that I believe would kick in for vsnprintf in qb_log call
stack as well.

(from the neighbour context
https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01772.html
from the neighbour context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88993
related to upcoming GCC 9)

@chrissie-c
Copy link
Contributor Author

Good spot! it just seemed a sensible suggestion at the time :)

@jnpkrn
Copy link
Contributor

jnpkrn commented Apr 30, 2019

Oh, and this likely requires even more considerations before being
ready for prime time (bigger messages means more likeliness of
non-atomic appends to the file):

https://lists.clusterlabs.org/pipermail/users/2019-April/025735.html

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

Successfully merging this pull request may close these issues.

3 participants