Skip to content

drivers/syslog: Make openlog() ident optional - #21853

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
jingfei195887:syslog-openlog-option
Nov 17, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
jingfei195887:syslog-openlog-option

Conversation

@jingfei195887

Copy link
Copy Markdown
Contributor

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 on SYSLOG, default !DEFAULT_SMALL):

  • On: same behavior as today: ident: / ident[pid]: before each message, and a copy to stderr with LOG_PERROR.
  • Off: openlog() and closelog() 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

  • Boards without DEFAULT_SMALL: no change. The option defaults to on.
  • Boards with DEFAULT_SMALL: syslog messages lose the openlog() ident and LOG_PID/LOG_PERROR handling unless the option is enabled.
  • No API change. No change to apps.

Testing

stm32f103-minimum:nsh, arm-none-eabi-gcc 10.3.1:

configuration text data bss
master 54032 464 2992
this PR, option off (default) 53728 464 2952
this PR, option on 54032 464 2992

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 of SYSLOG_NONE=y and CMake (option off: text 53720) also pass. All builds are free of warnings, and checkpatch.sh passes.

sim:nsh with a test program calling openlog("tst", LOG_PID | LOG_PERROR, LOG_USER) and then syslog():

option on:   tst[8]: olt-one 1
option off:  olt-one 1

@github-actions github-actions Bot added Area: Drivers Drivers issues Size: S The size of the change in this PR is small labels Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

arduino-mega2560

  • flash: .data -25 B, .text -550 B (-0.8%, 67,637 B / 262,144 B, total: 26% used)
  • sram: .bss -48 B, .data -25 B (-2.6%, 2,760 B / 8,192 B, total: 34% used)

hifive1-revb

  • flash: .text -408 B (-0.5%, 87,008 B / 4,194,304 B, total: 2% used)
  • sram: .bss -32 B (-0.8%, 4,028 B / 16,384 B, total: 25% used)

mirtoo

  • kseg0_progmem: .text -632 B (-0.9%, 69,080 B / 131,072 B, total: 53% used)
  • kseg1_datamem: .bss -48 B (-1.8%, 2,636 B / 32,256 B, total: 8% used)

stm32-nucleo-f103rb

  • flash: .text -340 B (-0.9%, 35,512 B / 131,072 B, total: 27% used)
  • sram: .bss -40 B (-1.6%, 2,508 B / 20,480 B, total: 12% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

Comment thread drivers/syslog/vsyslog.c Resolved
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]>
@xiaoxiang781216
xiaoxiang781216 merged commit 10998bb into apache:master Nov 17, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants