소스 검색

refactor: add debug switch for logging

Sam Jaffe 2 달 전
부모
커밋
9ec480bf4a
2개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  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"""