How to use the logzero.logger.fatal function in logzero

To help you get started, we’ve selected a few logzero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chaostoolkit / chaostoolkit-lib / chaoslib / run.py View on Github external
logger.fatal(str(i))
                event_registry.interrupted(experiment, journal)
            except (KeyboardInterrupt, SystemExit):
                journal["status"] = "interrupted"
                logger.warning("Received an exit signal, "
                               "leaving without applying rollbacks.")
                event_registry.signal_exit()
            else:
                hypo_pool.shutdown(wait=True)
                journal["status"] = journal["status"] or "completed"
                try:
                    journal["rollbacks"] = apply_rollbacks(
                        experiment, configuration, secrets, rollback_pool, dry)
                except InterruptExecution as i:
                    journal["status"] = "interrupted"
                    logger.fatal(str(i))
                except (KeyboardInterrupt, SystemExit):
                    journal["status"] = "interrupted"
                    logger.warning(
                        "Received an exit signal."
                        "Terminating now without running the "
                        "remaining rollbacks.")

            hypo_pool.shutdown(wait=True)
            journal["end"] = datetime.utcnow().isoformat()
            journal["duration"] = time.time() - started_at
            has_deviated = journal["deviated"]
            status = "deviated" if has_deviated else journal["status"]
            logger.info("Experiment ended with status: {s}".format(s=status))
            if has_deviated:
                logger.info(
                    "The steady-state has deviated, a weakness may have been "
github chaostoolkit / chaostoolkit / chaostoolkit / cli.py View on Github external
def discover(ctx: click.Context, package: str,
             discovery_path: str = "./discovery.json",
             no_system_info: bool = False,
             no_install: bool = False) -> Discovery:
    """Discover capabilities and experiments."""
    settings = load_settings(ctx.obj["settings_path"])
    try:
        notify(settings, DiscoverFlowEvent.DiscoverStarted, package)
        discovery = disco(
            package_name=package, discover_system=not no_system_info,
            download_and_install=not no_install)
    except DiscoveryFailed as err:
        notify(settings, DiscoverFlowEvent.DiscoverFailed, package, err)
        logger.debug("Failed to discover {}".format(package), exc_info=err)
        logger.fatal(str(err))
        return

    with open(discovery_path, "w") as d:
        d.write(json.dumps(discovery, indent=2, default=encoder))
    logger.info("Discovery outcome saved in {p}".format(
        p=discovery_path))

    notify(settings, DiscoverFlowEvent.DiscoverCompleted, discovery)
    return discovery
github chaostoolkit / chaostoolkit-lib / chaoslib / experiment.py View on Github external
"aborting now.", exc_info=True)
                else:
                    try:
                        state = run_steady_state_hypothesis(
                            experiment, config, secrets, dry=dry)
                        journal["steady_states"]["after"] = state
                        if state is not None and not state["steady_state_met"]:
                            journal["deviated"] = True
                            p = state["probes"][-1]
                            raise ActivityFailed(
                                "Steady state probe '{p}' is not in the given "
                                "tolerance so failing this experiment".format(
                                    p=p["activity"]["name"]))
                    except ActivityFailed as a:
                        journal["status"] = "failed"
                        logger.fatal(str(a))
        except ActivityFailed as a:
            logger.fatal(str(a))
        except InterruptExecution as i:
            journal["status"] = "interrupted"
            logger.fatal(str(i))
        except (KeyboardInterrupt, SystemExit):
            journal["status"] = "interrupted"
            logger.warning("Received an exit signal, "
                           "leaving without applying rollbacks.")
        else:
            journal["status"] = journal["status"] or "completed"

        has_deviated = journal["deviated"]
        journal_status = journal["status"]
        play_rollbacks = False
        if rollback_strategy == "always":
github chaostoolkit / chaostoolkit-lib / chaoslib / run.py View on Github external
secrets: Secrets, dry: bool = False) \
                                            -> Dict[str, Any]:
    """
    Run the hypothesis after the method and report to the journal if the
    experiment has deviated.
    """
    logger.debug("Running steady-state hypothesis after the method")
    state = run_steady_state_hypothesis(
        experiment, configuration, secrets, dry=dry)
    journal["steady_states"]["after"] = state
    if state is not None and \
            not state["steady_state_met"]:
        journal["deviated"] = True
        journal["status"] = "failed"
        p = state["probes"][-1]
        logger.fatal(
            "Steady state probe '{p}' is not in the "
            "given tolerance so failing this "
            "experiment".format(
                p=p["activity"]["name"]))
    return state
github chaostoolkit / chaostoolkit-lib / chaoslib / experiment.py View on Github external
"Steady state probe '{p}' is not in the given "
                        "tolerance so failing this experiment".format(
                            p=p["activity"]["name"]))
            except ActivityFailed as a:
                journal["steady_states"]["before"] = state
                journal["status"] = "failed"
                raise
            else:
                try:
                    journal["run"] = apply_activities(
                        experiment, config, secrets, activity_pool, dry)
                except InterruptExecution:
                    raise
                except Exception:
                    journal["status"] = "aborted"
                    logger.fatal(
                        "Experiment ran into an un expected fatal error, "
                        "aborting now.", exc_info=True)
                else:
                    try:
                        state = run_steady_state_hypothesis(
                            experiment, config, secrets, dry=dry)
                        journal["steady_states"]["after"] = state
                        if state is not None and not state["steady_state_met"]:
                            journal["deviated"] = True
                            p = state["probes"][-1]
                            raise ActivityFailed(
                                "Steady state probe '{p}' is not in the given "
                                "tolerance so failing this experiment".format(
                                    p=p["activity"]["name"]))
                    except ActivityFailed as a:
                        journal["status"] = "failed"
github chaostoolkit / chaostoolkit-lib / chaoslib / run.py View on Github external
event_registry: EventHandlerRegistry,
               dry: bool = False) -> Optional[List[Run]]:
    event_registry.start_method()
    try:
        state = apply_activities(
            experiment, configuration, secrets, activity_pool, journal, dry)
        journal["run"] = state
        event_registry.condition_completed(state)
        return journal["run"]
    except InterruptExecution:
        event_registry.condition_completed(None)
        raise
    except Exception:
        journal["status"] = "aborted"
        event_registry.condition_completed(None)
        logger.fatal(
            "Experiment ran into an un expected fatal error, "
            "aborting now.", exc_info=True)
github chaostoolkit / chaostoolkit-lib / chaoslib / run.py View on Github external
configuration: Configuration, secrets: Secrets,
                        dry: bool = False) -> Dict[str, Any]:
    """
    Run the hypothesis before the method and bail the execution if it did
    not pass.
    """
    logger.debug("Running steady-state hypothesis before the method")
    state = run_steady_state_hypothesis(
        experiment, configuration, secrets, dry=dry)
    journal["steady_states"]["before"] = state
    if state is not None and not state["steady_state_met"]:
        journal["steady_states"]["before"] = state
        journal["status"] = "failed"

        p = state["probes"][-1]
        logger.fatal(
            "Steady state probe '{p}' is not in the given "
            "tolerance so failing this experiment".format(
                p=p["activity"]["name"]))
    return state