Sfoglia il codice sorgente

refactor: add debug switch for logging

Sam Jaffe 5 mesi fa
parent
commit
9ec480bf4a
2 ha cambiato i file con 8 aggiunte e 1 eliminazioni
  1. 2 1
      src/cipy/__init__.py
  2. 6 0
      src/cipy/settings.py

+ 2 - 1
src/cipy/__init__.py

@@ -13,6 +13,7 @@ from cipy.common import Context, Factory, Inputs, Outputs, Ref, Status
 from cipy.shell import Shell
 from cipy.shell import Shell
 from cipy.workflow import Job, Matrix, MatrixParams, Workflow
 from cipy.workflow import Job, Matrix, MatrixParams, Workflow
 
 
+from . import settings
 from ._logging import CIFormatter
 from ._logging import CIFormatter
 
 
 _handler = logging.StreamHandler()
 _handler = logging.StreamHandler()
@@ -20,7 +21,7 @@ _handler.setFormatter(CIFormatter("%(asctime)s [%(name)s] %(message)s"))
 
 
 logging.basicConfig(datefmt="%Y-%m-%dT%H:%M:%S.%fZ",
 logging.basicConfig(datefmt="%Y-%m-%dT%H:%M:%S.%fZ",
                     handlers=[ _handler ],
                     handlers=[ _handler ],
-                    level=logging.INFO)
+                    level=logging.DEBUG if settings.DEBUG else logging.INFO)
 
 
 __all__ = [
 __all__ = [
     "Call",
     "Call",

+ 6 - 0
src/cipy/settings.py

@@ -1,5 +1,11 @@
 """Runtime/Buildtime Settings"""
 """Runtime/Buildtime Settings"""
 
 
+import os
+
 from typing import Final
 from typing import Final
 
 
 INTERACTIVE: Final[bool] = True
 INTERACTIVE: Final[bool] = True
+"""Are we in CLI/Interactive mode, or in CI mode?"""
+
+DEBUG: Final[bool] = "DEBUG" in os.environ
+"""Enable additional logging for debugging purposes"""