jingfei195887 opened a new pull request, #21853:
URL: https://github.com/apache/nuttx/pull/21853

   ## 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-#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
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to