Repository: snek5000/snek5000 (language: python)

Issue:
Logging issue: messages repeated twice
When I run https://github.com/exabl/snek5000-cbox/blob/main/doc/examples/run_sim.py, messages are repeated twice: once in color and then again but with the words "WARNING: " or "ERROR: " prepend.



Discussion / hints:
#36 (merged) replaces the logger module. See if this helps.
Nop, it does not help :slightly_frowning_face: 
I've just understood that it's related to the fact that I run 2 commands in the same scripts (`sim.make.list()` and `sim.make.exec()`)


We have the repetitions for all tutorials in the doc so I reopen.

Fix patch:
diff --git a/src/snek5000/log.py b/src/snek5000/log.py
index f778a6ae..79df6260 100644
--- a/src/snek5000/log.py
+++ b/src/snek5000/log.py
@@ -21,7 +21,15 @@ def create_handler(width=None):
 
 handler = create_handler()
 logger = logging.getLogger(__name__)
-logger.addHandler(handler)
+
+# adding a logging.StreamHandler leads to buggy logging
+# see https://github.com/snek5000/snek5000/issues/38
+try:
+    import rich
+except ImportError:
+    pass
+else:
+    logger.addHandler(handler)
 
 
 if os.getenv("SNEK_DEBUG"):


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index c15903e1..2e42a975 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -7,9 +7,7 @@
 from snek5000.output.base import Output, missing_config_filter
 from snek5000.config import ensure_config_file
 
-xdg_config = Path(
-    os.path.expandvars(os.getenv("XDG_CONFIG_HOME", "$HOME/.config"))
-)
+xdg_config = Path(os.path.expandvars(os.getenv("XDG_CONFIG_HOME", "$HOME/.config")))
 configfile_xdg_config = xdg_config / "snek5000.yml"
 
 
@@ -70,9 +68,7 @@ def test_find_configfile(caplog):
             assert f"{hostname}.yml" in message
             break
     else:
-        raise IOError(
-            "Expected a warning message when configuration file is missing"
-        )
+        raise IOError("Expected a warning message when configuration file is missing")
 
 
 @pytest.mark.skipif(