From 32981b2c199cf4cf5821ebab3a57b60c4ad72a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Tue, 13 Sep 2022 10:32:38 +0300 Subject: [PATCH] Switch to ECS logger --- meta-operator.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/meta-operator.py b/meta-operator.py index cd8cc5e..6372390 100755 --- a/meta-operator.py +++ b/meta-operator.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import asyncio +import ecs_logging import logging import os import random @@ -8,16 +9,21 @@ import yaml from kubernetes_asyncio.client.api_client import ApiClient from kubernetes_asyncio import client, config, watch from time import time -import useful.logs import argparse +# Get the Logger +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) + +# Add an ECS formatter to the Handler +handler = logging.StreamHandler() +handler.setFormatter(ecs_logging.StdlibFormatter()) +logger.addHandler(handler) + parser = argparse.ArgumentParser(description="Run handler for ClusterOperator CRD") parser.add_argument("--target", "-t", default="meta") args = parser.parse_args() -useful.logs.setup(json_fields={"msg": "message", "level": "levelname", "traceback": "exc_text"}) -logger = logging.getLogger() - MY_POD_NAMESPACE = os.environ["MY_POD_NAMESPACE"] LABEL_MANAGED_BY = "meta-operator"