gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: fix #8032


From: gnunet
Subject: [gnunet] branch master updated: fix #8032
Date: Mon, 08 Jan 2024 16:29:36 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new ad90694ec fix #8032
ad90694ec is described below

commit ad90694ecf9aa04d500e0d2f63261783f0ab8d10
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jan 8 16:29:32 2024 +0100

    fix #8032
---
 contrib/gana                  |  2 +-
 contrib/handbook              |  2 +-
 src/lib/util/common_logging.c | 61 +++++++++++++++++++++++++++++++------------
 3 files changed, 47 insertions(+), 18 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 40f6cf101..c1dc2dc97 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 40f6cf1015231663064eda98aa1e403cddd7b970
+Subproject commit c1dc2dc975742c929a523c22d91f7d4f82787230
diff --git a/contrib/handbook b/contrib/handbook
index 5c20e0aaa..e5b42badb 160000
--- a/contrib/handbook
+++ b/contrib/handbook
@@ -1 +1 @@
-Subproject commit 5c20e0aaa95c7cebc225d02231221d18fdcbdb53
+Subproject commit e5b42badb7450aee5367e70294a0f8b1595945eb
diff --git a/src/lib/util/common_logging.c b/src/lib/util/common_logging.c
index 458802a07..37c6064b8 100644
--- a/src/lib/util/common_logging.c
+++ b/src/lib/util/common_logging.c
@@ -771,7 +771,8 @@ GNUNET_log_setup (const char *comp,
 
 
 void
-GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls)
+GNUNET_logger_add (GNUNET_Logger logger,
+                   void *logger_cls)
 {
   struct CustomLogger *entry;
 
@@ -784,7 +785,8 @@ GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls)
 
 
 void
-GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls)
+GNUNET_logger_remove (GNUNET_Logger logger,
+                      void *logger_cls)
 {
   struct CustomLogger *pos;
   struct CustomLogger *prev;
@@ -820,8 +822,21 @@ output_message (enum GNUNET_ErrorType kind,
                 const char *datestr,
                 const char *msg)
 {
+  static int have_journald = -1;
   struct CustomLogger *pos;
 
+  if (-1 == have_journald)
+  {
+    /* systemd after version 231 sets this environment
+       variable if we are logging to journald. In this
+       case, skip outputting our component name, PID
+       and timestamp as journald already adds those. (#8032) */
+    if (NULL != getenv ("JOURNAL_STREAM"))
+      have_journald = 1;
+    else
+      have_journald = 0;
+  }
+
   /* only use the standard logger if no custom loggers are present */
   if ((NULL != GNUNET_stderr) && (NULL == loggers))
   {
@@ -834,7 +849,8 @@ output_message (enum GNUNET_ErrorType kind,
        * interactively, yet the same message shouldn't look
        * this way if the output is going to logfiles or robots
        * instead.
-       */fprintf (GNUNET_stderr, "* %s", msg);
+       */
+      fprintf (GNUNET_stderr, "* %s", msg);
     }
     else if (GNUNET_YES == current_async_scope.have_scope)
     {
@@ -850,22 +866,35 @@ output_message (enum GNUNET_ErrorType kind,
       GNUNET_assert (NULL != end);
       *end = '\0';
       skip_log = 0;
-      fprintf (GNUNET_stderr,
-               "%s %s(%s) %s %s",
-               datestr,
-               comp,
-               id_buf,
-               GNUNET_error_type_to_string (kind),
-               msg);
+      if (have_journald)
+        fprintf (GNUNET_stderr,
+                 "(%s) %s %s",
+                 id_buf,
+                 GNUNET_error_type_to_string (kind),
+                 msg);
+      else
+        fprintf (GNUNET_stderr,
+                 "%s %s(%s) %s %s",
+                 datestr,
+                 comp,
+                 id_buf,
+                 GNUNET_error_type_to_string (kind),
+                 msg);
     }
     else
     {
-      fprintf (GNUNET_stderr,
-               "%s %s %s %s",
-               datestr,
-               comp,
-               GNUNET_error_type_to_string (kind),
-               msg);
+      if (have_journald)
+        fprintf (GNUNET_stderr,
+                 "%s %s",
+                 GNUNET_error_type_to_string (kind),
+                 msg);
+      else
+        fprintf (GNUNET_stderr,
+                 "%s %s %s %s",
+                 datestr,
+                 comp,
+                 GNUNET_error_type_to_string (kind),
+                 msg);
     }
     fflush (GNUNET_stderr);
   }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]