xiaoxiang781216 commented on code in PR #16493: URL: https://github.com/apache/nuttx/pull/16493#discussion_r2138222779
########## drivers/syslog/Kconfig: ########## @@ -140,61 +140,94 @@ config SYSLOG_INTBUFSIZE comment "Formatting options" +config SYSLOG_RFC5424 + bool "Standard syslog format (RFC 5424)" + default n + ---help--- + Forces syslog logs to follow the RFC 5424 (syslog protocol) standard. + This allows for structured data elements, standard severity levels, + standard facilities, standard timestamps and other features that allow + syslogs to be compatible with other open source programs (such as + logging servers). + +if SYSLOG_RFC5424 + +comment "RFC5424 options" + +config SYSLOG_RFC5424_HOSTNAME + bool "Enable hostname field" + default n + ---help--- + Adds the HOSTNAME field to the RFC 5424 compatible syslog output. + +config SYSLOG_RFC5424_TIMEQUALITY + bool "timeQuality structured data" + depends on SYSLOG_TIMESTAMP Review Comment: remove depends on to decouple rfc5424 from the native log style option ########## drivers/syslog/Kconfig: ########## @@ -140,61 +140,94 @@ config SYSLOG_INTBUFSIZE comment "Formatting options" +config SYSLOG_RFC5424 + bool "Standard syslog format (RFC 5424)" + default n + ---help--- + Forces syslog logs to follow the RFC 5424 (syslog protocol) standard. + This allows for structured data elements, standard severity levels, + standard facilities, standard timestamps and other features that allow + syslogs to be compatible with other open source programs (such as + logging servers). + +if SYSLOG_RFC5424 + +comment "RFC5424 options" + +config SYSLOG_RFC5424_HOSTNAME + bool "Enable hostname field" + default n + ---help--- + Adds the HOSTNAME field to the RFC 5424 compatible syslog output. + +config SYSLOG_RFC5424_TIMEQUALITY + bool "timeQuality structured data" + depends on SYSLOG_TIMESTAMP + default n + ---help--- + Enables the RFC 5424 'timeQuality' structured data element, which describes the + quality of the timestamp sent. + +endif # SYSLOG_RFC5424 Review Comment: let's change to else/endif: ``` if SYSLOG_RFC5424 comment "RFC5424 options" config SYSLOG_RFC5424_HOSTNAME ... else config SYSLOG_TIMESTAMP ... endif ``` ########## drivers/syslog/Make.defs: ########## @@ -24,7 +24,14 @@ # Include SYSLOG Infrastructure ifeq ($(CONFIG_SYSLOG),y) -CSRCS += vsyslog.c syslog_channel.c + +ifeq ($(CONFIG_SYSLOG_RFC5424),y) + CSRCS += vsyslog_rfc5424.c +else + CSRCS += vsyslog.c +endif + +CSRCS += syslog_channel.c CSRCS += syslog_write.c syslog_flush.c Review Comment: merge into one line ########## drivers/syslog/vsyslog_rfc5424.c: ########## @@ -0,0 +1,266 @@ +/**************************************************************************** + * drivers/syslog/vsyslog_rfc5424.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <errno.h> +#include <stdio.h> +#include <syslog.h> + +#include <nuttx/arch.h> +#include <nuttx/clock.h> +#include <nuttx/init.h> +#include <nuttx/streams.h> +#include <nuttx/syslog/syslog.h> + +#include "syslog.h" + +/**************************************************************************** + * Preprocessor definitions + ****************************************************************************/ + +/* Get logging severity level from priority */ + +#define SEVERITY(prio) ((prio) & 0x7) + +/* Get logging facility from priority */ + +#define FACILITY(prio) (((prio) & (~0x7)) >> 3) Review Comment: let's define the follow official macro like glibc: ``` #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ #define LOG_PRI(p) ((p) & LOG_PRIMASK) /* extract priority */ #define LOG_MAKEPRI(fac, pri) ((fac) | (pri)) ``` and move include/syslog.h to avoid the duplication. -- 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: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org