From beced1af73772b9e1229cd9c894fc42704369f38 Mon Sep 17 00:00:00 2001 From: Dave Conroy Date: Fri, 6 Jan 2023 09:48:19 -0800 Subject: [PATCH] Add Timestamps to Console Logs --- README.md | 2 +- install/usr/sbin/cloudflare-companion | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d69f679..c0693d4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # github.com/tiredofit/docker-traefik-cloudflare-companion [![GitHub release](https://img.shields.io/github/v/tag/tiredofit/docker-traefik-cloudflare-companion?style=flat-square)](https://github.com/tiredofit/docker-traefik-cloudflare-companion/releases/latest) -[![Build Status](https://img.shields.io/github/workflow/status/tiredofit/docker-traefik-cloudflare-companion/build?style=flat-square)](https://github.com/tiredofit/docker-traefik-cloudflare-companion/actions?query=workflow%3Abuild) +[![Build Status](https://img.shields.io/github/actions/workflow/status/tiredofit/docker-traefik-cloudflare-companion.git/main.yml?branch=main&style=flat-square)](https://github.com/tiredofit/docker-traefik-cloudflare-companion.git/actions) [![Docker Stars](https://img.shields.io/docker/stars/tiredofit/traefik-cloudflare-companion.svg?style=flat-square&logo=docker)](https://hub.docker.com/r/tiredofit/traefik-cloudflare-companion/) [![Docker Pulls](https://img.shields.io/docker/pulls/tiredofit/traefik-cloudflare-companion.svg?style=flat-square&logo=docker)](https://hub.docker.com/r/tiredofit/traefik-cloudflare-companion/) [![Become a sponsor](https://img.shields.io/badge/sponsor-tiredofit-181717.svg?logo=github&style=flat-square)](https://github.com/sponsors/tiredofit) diff --git a/install/usr/sbin/cloudflare-companion b/install/usr/sbin/cloudflare-companion index 9f8159f..40e91bc 100755 --- a/install/usr/sbin/cloudflare-companion +++ b/install/usr/sbin/cloudflare-companion @@ -29,18 +29,27 @@ DRY_RUN = os.environ.get('DRY_RUN', "FALSE") logger = logging.getLogger(__name__) DEBUG = False VERBOSE = False +date_fmt = "%Y-%m-%dT%H:%M:%S%z" if CONTAINER_LOG_LEVEL.upper() == "DEBUG": logger.setLevel(logging.DEBUG) + fmt = "%(asctime)s %(levelname)s %(lineno)d | %(message)s" DEBUG = True if CONTAINER_LOG_LEVEL.upper() == "VERBOSE": logger.setLevel(logging.DEBUG) + fmt = "%(asctime)s %(levelname)s | %(message)s" DEBUG = True VERBOSE = True +if CONTAINER_LOG_LEVEL.upper() == "NOTICE": + fmt = "%(asctime)s %(levelname)s | %(message)s" + +if CONTAINER_LOG_LEVEL.upper() == "INFO": + fmt = "%(asctime)s %(levelname)s | %(message)s" + ch = logging.StreamHandler() -formatter = logging.Formatter('[%(levelname)s] %(message)s') +formatter = logging.Formatter(fmt, date_fmt) ch.setFormatter(formatter) logger.addHandler(ch) @@ -101,7 +110,7 @@ def init_doms_from_env(): for dom in doms: logger.debug("Domain Configuration: %s", dom) - + return doms @@ -138,9 +147,9 @@ def is_domain_excluded(name, dom): excluded_sub_domains = dom['excluded_sub_domains'] for sub_dom in excluded_sub_domains: - + fqdn_with_sub_dom = sub_dom + '.' + dom['name'] - + if name.find(fqdn_with_sub_dom) != -1: logger.info('Ignoring %s because it falls until excluded sub domain: %s', name, sub_dom) return True