Skip to content

Commit

Permalink
Add Timestamps to Console Logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tiredofit committed Jan 6, 2023
1 parent 1a322e9 commit beced1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
17 changes: 13 additions & 4 deletions install/usr/sbin/cloudflare-companion
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -101,7 +110,7 @@ def init_doms_from_env():

for dom in doms:
logger.debug("Domain Configuration: %s", dom)

return doms


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit beced1a

Please sign in to comment.