Repository navigation
drivers/syslog: Make openlog() ident optional - #21853
Merged
xiaoxiang781216 merged 1 commit intoNov 17, 2026
Merged
Conversation
jingfei195887
requested review from
Donny9,
GUIDINGLI,
anchao,
fjpanag,
jerpelea,
linguini1,
pussuw and
xiaoxiang781216
as code owners
November 13, 2026 15:54
1 task done
|
acassis
approved these changes
Nov 14, 2026
GUIDINGLI
approved these changes
Nov 16, 2026
The openlog() support keeps a 32-byte ident and the options in every task group and formats them into each syslog header, which costs about 300 bytes of flash on small targets. Calling openlog() is optional in POSIX, and without it the messages carry no ident. Add SYSLOG_OPENLOG, defaulting to !DEFAULT_SMALL. When it is off, openlog() and closelog() remain as functions that do nothing, so programs still build and link. stm32f103-minimum:nsh: flash -304 bytes, bss -40 bytes. Signed-off-by: jingfei <[email protected]>
jingfei195887
force-pushed
the
syslog-openlog-option
branch
from
November 16, 2026 05:26
ba035bf to
36a3916
Compare
GUIDINGLI
approved these changes
Nov 17, 2026
michallenc
approved these changes
Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The openlog() support from #21128 keeps a 32-byte ident and the options in every task group and formats them into each syslog header. On small targets this costs about 300 bytes of flash and 40 bytes of RAM.
Calling openlog() is optional in POSIX ("it will automatically be called by syslog() if necessary, in which case ident will default to NULL"), as @acassis pointed out in #20414.
This PR adds
CONFIG_SYSLOG_OPENLOG(depends onSYSLOG, default!DEFAULT_SMALL):ident:/ident[pid]:before each message, and a copy to stderr withLOG_PERROR.openlog()andcloselog()remain as real functions that do nothing, so programs such as tcpd that call them still build and link. The messages have no ident, as when a program never calls openlog(), and the syslog header goes back to its pre-libs/libc/syslog: Implement openlog() and closelog(). #21128 form.The documentation and the
<syslog.h>comment describe the option.Impact
DEFAULT_SMALL: no change. The option defaults to on.DEFAULT_SMALL: syslog messages lose the openlog() ident andLOG_PID/LOG_PERRORhandling unless the option is enabled.Testing
stm32f103-minimum:nsh, arm-none-eabi-gcc 10.3.1:The option-on image is the same size as master. With
SYSLOG_RFC5424=y, turning the option off saves 264 B of text and 40 B of bss. Builds ofSYSLOG_NONE=yand CMake (option off: text 53720) also pass. All builds are free of warnings, andcheckpatch.shpasses.sim:nsh with a test program calling
openlog("tst", LOG_PID | LOG_PERROR, LOG_USER)and thensyslog():