Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
set log levels in run.py based on logging_levels.json.gz
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Feb 26, 2018
1 parent 721353f commit 611214e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions alphatwirl/concurrently/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import tarfile
import signal
import gzip
import json
import logging
import cProfile, pstats

from io import StringIO, BytesIO
Expand Down Expand Up @@ -77,6 +79,28 @@ def print_logs(error):

##__________________________________________________________________||
def setup():
setup_logging()
setup_python_modules()

def setup_logging():
path = 'logging_levels.json.gz'
if not os.path.isfile(path):
return
with gzip.GzipFile(path, 'r') as f:
loglevel_dict = json.loads(f.read().decode('utf-8'))

for name, level in loglevel_dict.items():
logger = logging.getLogger(name)
logger.setLevel(level)

handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logging.getLogger('').addHandler(handler)


def setup_python_modules():

dirname = 'python_modules'
tarname = dirname + '.tar.gz'

Expand Down

0 comments on commit 611214e

Please sign in to comment.