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 #!/usr/bin/env python3
import asyncio import asyncio
import ecs_logging
import logging import logging
import os import os
import random import random
@ -8,16 +9,21 @@ import yaml
from kubernetes_asyncio.client.api_client import ApiClient from kubernetes_asyncio.client.api_client import ApiClient
from kubernetes_asyncio import client, config, watch from kubernetes_asyncio import client, config, watch
from time import time from time import time
import useful.logs
import argparse 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 = argparse.ArgumentParser(description="Run handler for ClusterOperator CRD")
parser.add_argument("--target", "-t", default="meta") parser.add_argument("--target", "-t", default="meta")
args = parser.parse_args() 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"] MY_POD_NAMESPACE = os.environ["MY_POD_NAMESPACE"]
LABEL_MANAGED_BY = "meta-operator" LABEL_MANAGED_BY = "meta-operator"