Skip to content

Commit

Permalink
Restructure loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
berkayurun authored and aewag committed Apr 27, 2023
1 parent eb94dad commit 2806c43
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from pathlib import Path
import pickle
import subprocess
import sys
import time

import pandas as pd
Expand Down Expand Up @@ -627,6 +628,26 @@ def process_arguments(args):
return parguments


def init_logging():
logging_level = logging.INFO
handler_list = []

stream_handler = logging.StreamHandler(sys.stdout)
stream_handler.setLevel(logging.INFO)
handler_list.append(stream_handler)

if args.debug:
file_handler = logging.FileHandler("log.txt")
handler_list.append(file_handler)
logging_level = logging.DEBUG

logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s : %(message)s",
level=logging_level,
handlers=handler_list,
)


if __name__ == "__main__":
"""
Main function to programm
Expand All @@ -637,13 +658,7 @@ def process_arguments(args):

parguments = process_arguments(args)

logging_level = logging.INFO
if args.debug:
logging_level = logging.DEBUG
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s : %(message)s",
level=logging_level,
)
init_logging()

controller(
args.hdf5file, # hdf5path
Expand Down

0 comments on commit 2806c43

Please sign in to comment.