mirror of
https://github.com/apache/nuttx.git
synced 2026-03-23 22:43:57 +08:00
This commit introduces a new Kconfig option SYSLOG_TIMESTAMP_MS to allowconfiguring syslog timestamps to use milliseconds (ms) instead of the default microseconds (µs). Key changes: 1. Add CONFIG_SYSLOG_TIMESTAMP_MS boolean Kconfig option (depends on SYSLOG_TIMESTAMP), default disabled. This option lets users choose between millisecond and microsecond precision in syslog timestamps. 2. Modify the timestamp format string in nx_vsyslog(): a. When CONFIG_SYSLOG_TIMESTAMP_MS is enabled: Use [%5ju.%03ld] (3 digits for ms). b. When disabled (default): Retain original [%5ju.%06ld] (6 digits for µs). 3. Adjust the timestamp value calculation: a. For ms: Divide nanoseconds by NSEC_PER_MSEC (1,000,000) to get millisecond value. b. For µs (default): Retain division by NSEC_PER_USEC (1,000) for microsecond value. This enhancement provides flexibility in syslog timestamp precision: 1. Millisecond precision reduces log line length and is sufficient for many use cases. 2. Maintains backward compatibility (microseconds remain the default). 3. The Kconfig dependency ensures the option is only visible when timestamps are enabled. The change is fully conditional and has no impact on existing behavior unless the new option is explicitly enabled. Signed-off-by: liwangzhu <liwangzhu@bytedance.com> Signed-off-by: chao an <anchao.archer@bytedance.com>