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

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   An option from Xiaomi Vela that keeps the default syslog channel 
(`up_putc()`) quiet until an assertion: the console then shows the crash 
output, while the other channels (for example the RAMLOG) get all messages as 
before.
   
   - **syslog: add option to use syslog default only in panic**: 
`CONFIG_SYSLOG_DEFAULT_PANIC_ONLY` (depends on `SYSLOG_IOCTL`). The default 
channel starts with `SYSLOG_CHANNEL_DISABLE` set, and a panic notifier enables 
it when an assertion is reported. With `SYSLOG_CONSOLE_LEVEL` as well, the 
initializer of `g_default_channel` would get two values for `sc_state` (this 
one and the placeholder of the console level), so the commit gives 
`sc_dropmask` by name; this part is new compared with the original Vela commit, 
which predates `SYSLOG_CONSOLE_LEVEL`.
   - **syslog: switch default channel disable from compile-time to runtime**: 
the channel no longer starts disabled, and the notifier clears only 
`SYSLOG_CHANNEL_DISABLE` instead of the whole state.
   - **syslog: set default channel to disabled state when PANIC_ONLY enabled**: 
the channel starts disabled again, now with `SYSLOG_CHANNEL_DISABLE` instead of 
`true`, so it is quiet also before anything uses `SYSLOGIOC_SETFILTER`.
   
   A later Vela change that enables the channel only at `PANIC_KERNEL_FINAL` 
relies on a RAMLOG dump on panic that master does not have; it is not part of 
this PR.
   
   ## Impact
   
   - New option `CONFIG_SYSLOG_DEFAULT_PANIC_ONLY`, default n: nothing changes 
unless it is enabled.
   - With the option, the default channel writes nothing until the first 
assertion. The panic notifiers run at the start of every assertion, also for a 
task assertion that the system survives (`PANIC_TASK`), and the channel stays 
enabled from then on. `SYSLOGIOC_SETFILTER` can still enable or disable it at 
run time.
   - `g_default_channel` gives `sc_dropmask` by name; the value is the same 
`SYSLOG_CONSOLE_DROPMASK`.
   - No API change.
   
   ## Testing
   
   Host: Ubuntu 22.04 x86_64, GCC 13.4.0 (sim), Arm GNU Toolchain 13.2.rel1, 
CMake 3.23 + Ninja 1.10. Base: master b5a3bff956b.
   
   `./tools/checkpatch.sh -c -u -m -g HEAD~3..HEAD` passes.
   
   Every commit builds without warnings (CMake, incremental) for `sim:nsh` with 
`SYSLOG_IOCTL` and `SYSLOG_DEFAULT_PANIC_ONLY`, with `SYSLOG_DROPMASK` and 
`SYSLOG_CONSOLE_LEVEL=3`, and with all of them. The head also builds with all 
of them for `sim:smp` and `qemu-armv7a:nsh`, and with Make for `sim:nsh`.
   
   `sim:nsh` with a local test program (not part of this PR) that logs one 
`LOG_ERR` and one `LOG_INFO` message, and then calls `PANIC()` when it gets an 
argument:
   
   | | `LOG_ERR` | `LOG_INFO` | assertion dump |
   |---|---|---|---|
   | master | shown | shown | shown |
   | master, `SYSLOG_CONSOLE_LEVEL=3` | shown | dropped | shown |
   | this PR, `SYSLOG_DEFAULT_PANIC_ONLY` | dropped | dropped | shown |
   | this PR, `SYSLOG_DEFAULT_PANIC_ONLY` and `SYSLOG_CONSOLE_LEVEL=3` | 
dropped | dropped | shown |
   | this PR, `SYSLOG_CONSOLE_LEVEL=3` | shown | dropped | shown |
   
   this PR with `SYSLOG_DEFAULT_PANIC_ONLY`:
   
   ```
   nsh> hello
   sltest: done
   nsh> hello panic
   dump_assert_info: Assertion failed panic: at file: :0 task: hello process: 
hello 0x400b9329
   sched_dumpstack: backtrace| 9: 0x0000000040002ce1 0x000000004008da85 
0x000000004008909f ...
   ```
   
   The branch merges cleanly with master 4f8706c4b35 (no change under 
`drivers/syslog` since the base) and with #22341, the other recent open PR that 
changes `drivers/syslog/Kconfig`.
   
   Not tested: real hardware.
   


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