fjpanag commented on a change in pull request #3050:
URL: https://github.com/apache/incubator-nuttx/pull/3050#discussion_r599683602



##########
File path: drivers/syslog/syslog_channel.c
##########
@@ -135,14 +139,82 @@ static int syslog_default_putc(int ch)
 
 int syslog_channel(FAR const struct syslog_channel_s *channel)
 {
+#if (CONFIG_SYSLOG_MAX_CHANNELS != 1)
+  int i;
+#endif
+
   DEBUGASSERT(channel != NULL);
 
   if (channel != NULL)
     {
       DEBUGASSERT(channel->sc_putc != NULL && channel->sc_force != NULL);
 
-      g_syslog_channel = channel;
+#if (CONFIG_SYSLOG_MAX_CHANNELS == 1)
+      g_syslog_channel[0] = channel;
       return OK;
+#else
+      for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++)
+        {
+          if (g_syslog_channel[i] == NULL)
+            {
+              g_syslog_channel[i] = channel;
+              return OK;
+            }
+          else if (g_syslog_channel[i] == channel)
+            {
+              return OK;
+            }
+        }
+#endif
+    }
+
+  return -EINVAL;
+}
+
+/****************************************************************************
+ * Name: syslog_channel_remove
+ *
+ * Description:
+ *   Removes an already configured SYSLOG channel from the list of used
+ *   channels.
+ *
+ * Input Parameters:
+ *   channel - Provides the interface to the channel to be removed.
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success.  A negated errno value is returned
+ *   on any failure.
+ *
+ ****************************************************************************/
+
+int syslog_channel_remove(FAR const struct syslog_channel_s *channel)

Review comment:
       I am sorry but I cannot see what you describe...
   
   Here is a stack trace while the logger is outputing characters:
   ![Screenshot from 2021-03-23 
17-08-28](https://user-images.githubusercontent.com/46975045/112172814-b2578900-8bfd-11eb-8249-42b1f00ed222.png)
   
   I don't see in any of these functions any kind of buffering.
   
   ---
   
   In fact is was very easy to replicate what I imagined above.  
   I did:
   ```c
        task_create("test1", 128, 2048, test_th, 0);
        task_create("test2", 129, 2048, test_th, 0);
   ```
   
   and
   ```c
   int test_th(int argc, char ** argv)
   {
        while(1)
        {
                usleep(rand() % 10000);
                syslog(LOG_INFO, "A test message.\n");
        }
   }
   ```
   
   And I got this awesome output:
   
   
![image](https://user-images.githubusercontent.com/46975045/112173149-fd719c00-8bfd-11eb-8c10-d367adf26592.png)
   
   *Note!* You may not see this happen usually, because the default NuttX 
scheduler frequency is very coarse.  
   And *usually* the output has finished, before the next thread takes over. I 
had to set the scheduler frequency to 1kHz for this example (or you may use a 
log channel that needs more than 10ms to output everything completely).
   




-- 
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:
us...@infra.apache.org


Reply via email to