Bug 15558 - samba-gpupdate logging doesn't work
Summary: samba-gpupdate logging doesn't work
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Python (show other bugs)
Version: 4.19.3
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Jule Anger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-19 16:11 UTC by Andreas Schneider
Modified: 2024-02-19 10:47 UTC (History)
4 users (show)

See Also:


Attachments
patch for 4.19 and 4.20 (1.14 KB, patch)
2024-01-30 08:20 UTC, Andreas Schneider
pfilipensky: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schneider 2024-01-19 16:11:14 UTC
samba-gpupdate -d3 should print log messages issued with log.info(). However this doesn't work. I have the following patch:

diff --git a/python/samba/gp/util/logging.py b/python/samba/gp/util/logging.py
index 9e70891b62c..1bc7f9bd9e2 100644
--- a/python/samba/gp/util/logging.py
+++ b/python/samba/gp/util/logging.py
@@ -26,6 +26,7 @@ import sys
 logger = logging.getLogger()
 def logger_init(name, log_level):
     logger = logging.getLogger(name)
+    print("XXXXXX log_level=", log_level)
     logger.addHandler(logging.StreamHandler(sys.stdout))
     logger.setLevel(logging.CRITICAL)
     if log_level == 1:
@@ -33,6 +34,7 @@ def logger_init(name, log_level):
     elif log_level == 2:
         logger.setLevel(logging.WARNING)
     elif log_level == 3:
+        print("XXXXXX setting log level to logging.INFO")
         logger.setLevel(logging.INFO)
     elif log_level >= 4:
         logger.setLevel(logging.DEBUG)
@@ -69,6 +71,8 @@ class log(object):
         if data is None:
             data = {}
         msg = message_with_code('I', message)
+        print("XXXXXX effective log level: ", logger.getEffectiveLevel())
+        logger.info("XXXXXX What a wurst!")
         logger.info(slogm(msg, data))
         return msg
 
When running gpupdate I can see

XXXXXX log_level= 3                                                                                                                                                                  
XXXXXX setting log level to logging.INFO
XXXXXX effective log level:  30

However I don't get the line with "What a wurst!". I have no idea what's wrong here.
Comment 1 Andreas Schneider 2024-01-19 16:24:22 UTC
I think one issue is, that there are two logging instances, in line 26 and 28.
Comment 2 Andreas Schneider 2024-01-19 16:36:41 UTC
A possible fix would be:

 python/samba/gp/util/logging.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/python/samba/gp/util/logging.py b/python/samba/gp/util/logging.py
index 9e70891b62c..da085d8d7e6 100644
--- a/python/samba/gp/util/logging.py
+++ b/python/samba/gp/util/logging.py
@@ -23,9 +23,10 @@ import gettext
 import random
 import sys
 
-logger = logging.getLogger()
+logger = logging.getLogger("gp")
+
+
 def logger_init(name, log_level):
-    logger = logging.getLogger(name)
     logger.addHandler(logging.StreamHandler(sys.stdout))
     logger.setLevel(logging.CRITICAL)
     if log_level == 1:

The better solution would be if the log class has an init function and the logger is stored in the class ...
Comment 3 Samba QA Contact 2024-01-30 07:19:04 UTC
This bug was referenced in samba master:

145194071b10c4c1857f28fe79c57fd63ffab889
Comment 4 Andreas Schneider 2024-01-30 08:20:49 UTC
Created attachment 18238 [details]
patch for 4.19 and 4.20
Comment 5 Andreas Schneider 2024-01-30 08:56:10 UTC
Jule, please apply the patch to 4.19 and 4.20. Thanks!
Comment 6 Jule Anger 2024-02-05 09:19:50 UTC
Pushed to autobuild-v4-{20,19}-test.
Comment 7 Samba QA Contact 2024-02-05 12:35:14 UTC
This bug was referenced in samba v4-19-test:

60514eb68362ff883b7406fe03515d1439fb12a2
Comment 8 Samba QA Contact 2024-02-05 14:05:04 UTC
This bug was referenced in samba v4-20-test:

9e946a8ddd37ac8286c08293d1509260520f252e
Comment 9 Jule Anger 2024-02-06 09:28:02 UTC
Closing out bug report.

Thanks!
Comment 10 Samba QA Contact 2024-02-12 19:54:49 UTC
This bug was referenced in samba v4-20-stable (Release samba-4.20.0rc2):

9e946a8ddd37ac8286c08293d1509260520f252e
Comment 11 Samba QA Contact 2024-02-19 10:47:43 UTC
This bug was referenced in samba v4-19-stable (Release samba-4.19.5):

60514eb68362ff883b7406fe03515d1439fb12a2