Switch to ECS logger
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Lauri Võsandi 2022-09-13 10:32:38 +03:00
parent bd9fd49705
commit 32981b2c19

View File

@ -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"