You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/01/10 14:56:53 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #2621: Added formatted timestamps in syslog.

xiaoxiang781216 commented on a change in pull request #2621:
URL: https://github.com/apache/incubator-nuttx/pull/2621#discussion_r554578021



##########
File path: drivers/syslog/Kconfig
##########
@@ -102,15 +102,59 @@ config SYSLOG_TIMESTAMP
 	---help---
 		Prepend timestamp to syslog message.
 
+choice
+	prompt "Timestamp format"
+	depends on SYSLOG_TIMESTAMP
+
+config SYSLOG_TIMESTAMP_SYSTIME

Review comment:
       remove, nobody reference SYSLOG_TIMESTAMP_SYSTIME

##########
File path: drivers/syslog/Kconfig
##########
@@ -102,15 +102,59 @@ config SYSLOG_TIMESTAMP
 	---help---
 		Prepend timestamp to syslog message.
 
+choice
+	prompt "Timestamp format"
+	depends on SYSLOG_TIMESTAMP
+
+config SYSLOG_TIMESTAMP_SYSTIME
+	bool "System time"
+	default y
+	---help---
+		Use the system timer for timestamp.
+
 config SYSLOG_TIMESTAMP_REALTIME
-	bool "Use wall-clock for syslog timestamp"
+	bool "Wall-clock time"
 	default n
-	depends on SYSLOG_TIMESTAMP
 	---help---
 		Use wall-clock (CLOCK_REALTIME) for timestamp.  By default,
 		CLOCK_MONOTONIC, if enabled, will be used or the system timer
 		is not.
 
+config SYSLOG_TIMESTAMP_FORMATED

Review comment:
       Why SYSLOG_TIMESTAMP_FORMATED can't work with CLOCK_MONOTONIC(use choice here)? From the code, the format work with all timing source.

##########
File path: drivers/syslog/vsyslog.c
##########
@@ -132,8 +133,29 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
 #if defined(CONFIG_SYSLOG_TIMESTAMP)
   /* Pre-pend the message with the current time, if available */
 
+#if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATED)
+  time_t time;
+  struct tm * tm;
+  char date_buf[CONFIG_SYSLOG_TIMESTAMP_BUFFER];
+
+  time = ts.tv_sec;
+#if defined(CONFIG_SYSLOG_TIMESTAMP_LOCALTIME)
+  tm = localtime(&time);
+#else
+  tm = gmtime(&time);

Review comment:
       change to gmtime_r

##########
File path: drivers/syslog/Kconfig
##########
@@ -102,15 +102,59 @@ config SYSLOG_TIMESTAMP
 	---help---
 		Prepend timestamp to syslog message.
 
+choice
+	prompt "Timestamp format"
+	depends on SYSLOG_TIMESTAMP
+
+config SYSLOG_TIMESTAMP_SYSTIME
+	bool "System time"
+	default y
+	---help---
+		Use the system timer for timestamp.
+
 config SYSLOG_TIMESTAMP_REALTIME
-	bool "Use wall-clock for syslog timestamp"
+	bool "Wall-clock time"
 	default n
-	depends on SYSLOG_TIMESTAMP
 	---help---
 		Use wall-clock (CLOCK_REALTIME) for timestamp.  By default,
 		CLOCK_MONOTONIC, if enabled, will be used or the system timer
 		is not.
 
+config SYSLOG_TIMESTAMP_FORMATED
+	bool "Formatted wall-clock time"
+	---help---
+		Use wall-clock (CLOCK_REALTIME) for timestamp.  By default,

Review comment:
       Remove, not relate to this option.

##########
File path: drivers/syslog/vsyslog.c
##########
@@ -132,8 +133,29 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
 #if defined(CONFIG_SYSLOG_TIMESTAMP)
   /* Pre-pend the message with the current time, if available */
 
+#if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATED)
+  time_t time;
+  struct tm * tm;
+  char date_buf[CONFIG_SYSLOG_TIMESTAMP_BUFFER];

Review comment:
       move to the begin of the function per coding style.

##########
File path: drivers/syslog/Kconfig
##########
@@ -102,15 +102,59 @@ config SYSLOG_TIMESTAMP
 	---help---
 		Prepend timestamp to syslog message.
 
+choice
+	prompt "Timestamp format"
+	depends on SYSLOG_TIMESTAMP
+
+config SYSLOG_TIMESTAMP_SYSTIME
+	bool "System time"
+	default y
+	---help---
+		Use the system timer for timestamp.
+
 config SYSLOG_TIMESTAMP_REALTIME
-	bool "Use wall-clock for syslog timestamp"
+	bool "Wall-clock time"
 	default n
-	depends on SYSLOG_TIMESTAMP
 	---help---
 		Use wall-clock (CLOCK_REALTIME) for timestamp.  By default,
 		CLOCK_MONOTONIC, if enabled, will be used or the system timer
 		is not.
 
+config SYSLOG_TIMESTAMP_FORMATED
+	bool "Formatted wall-clock time"

Review comment:
       Remove wall-clock since the format apply to real time, mononic time and system time.

##########
File path: drivers/syslog/vsyslog.c
##########
@@ -132,8 +133,29 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
 #if defined(CONFIG_SYSLOG_TIMESTAMP)
   /* Pre-pend the message with the current time, if available */
 
+#if defined(CONFIG_SYSLOG_TIMESTAMP_FORMATED)
+  time_t time;
+  struct tm * tm;
+  char date_buf[CONFIG_SYSLOG_TIMESTAMP_BUFFER];
+
+  time = ts.tv_sec;
+#if defined(CONFIG_SYSLOG_TIMESTAMP_LOCALTIME)
+  tm = localtime(&time);

Review comment:
       change to localtime_r




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org