Skip to content

Commit

Permalink
adjust logger
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Hellegouarch <[email protected]>
  • Loading branch information
Lawouach committed Feb 20, 2024
1 parent 53c60fd commit 9b88681
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
### Changed

* Bump dependencies
* Adjusted for chaostoolkit-lib 1.42.0 changes around logging

## [0.25.2][]

Expand Down
2 changes: 1 addition & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ dependencies = [
"ruamel.yaml>=0.17.21",
"rich>=13.3.1",
"chaostoolkit-addons>=0.4.0",
"chaostoolkit>=1.15.0",
"chaostoolkit-lib>=1.33.1",
"chaostoolkit>=1.19.0",
"chaostoolkit-lib>=1.42.0",
"chaostoolkit-reliably>=0.22.0",
"orjson>=3.8.10",
"pydantic-settings>=2.0.0",
Expand Down
10 changes: 6 additions & 4 deletions reliably_cli/services/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from chaoslib import convert_vars, exit as chaos_exit, merge_vars
from chaoslib.control import load_global_controls
from chaoslib.experiment import ensure_experiment_is_valid, run_experiment
from chaoslib.log import configure_logger
from chaoslib.settings import CHAOSTOOLKIT_CONFIG_PATH, load_settings
from chaoslib.types import Dry, Journal, Schedule, Strategy
from ruamel.yaml import YAML
Expand Down Expand Up @@ -273,7 +274,7 @@ def run_chaostoolkit(
var_files: list[Path],
control_files: list[Path],
) -> Journal:
logger = logging.getLogger("logzero_default")
logger = logging.getLogger("chaostoolkit")

logger.info("#" * 80)

Expand Down Expand Up @@ -387,7 +388,8 @@ def reconfigure_chaostoolkit_logger(
) -> Generator[logging.Logger, None, None]:
from chaosreliably import attach_log_stream_handler

ctk_logger = logging.getLogger("logzero_default")
configure_logger(verbose=True)
ctk_logger = logging.getLogger("chaostoolkit")

for handler in list(ctk_logger.handlers):
ctk_logger.removeHandler(handler)
Expand Down Expand Up @@ -454,15 +456,15 @@ def load_experiment(url: str) -> dict[str, Any]:


def _new_terminate_now(signum: int, frame: FrameType = None) -> None:
logger = logging.getLogger("logzero_default")
logger = logging.getLogger("chaostoolkit")
logger.critical("Caught SIGTERM, signaling to the experiment it must end")

raise SystemExit(30)


def rewire_exit_signal_from_ctk() -> None:
if os.getenv("RELIABLY_CATCH_SIGTERM_BEFORE_CHAOSTOOLKIT") == "1":
logger = logging.getLogger("logzero_default")
logger = logging.getLogger("chaostoolkit")
logger.info("Re-wiring SIGTERM handler to Reliably")

chaos_exit._terminate_now = _new_terminate_now

0 comments on commit 9b88681

Please sign in to comment.