Refactor logging configuration

develop
Chris Leaman 6 years ago
parent e50fadb35c
commit a94fdd2dfb

@ -6,7 +6,7 @@ import os
import pandas as pd
from utils import setup_logging
from logs import setup_logging
logger = setup_logging()

@ -8,7 +8,7 @@ import pandas as pd
from scipy import stats
from analysis import runup_models
from utils import setup_logging
from logs import setup_logging
logger = setup_logging()

@ -5,7 +5,7 @@ Estimates the forecasted storm impacts based on the forecasted water level and d
import click
import pandas as pd
from utils import setup_logging
from logs import setup_logging
logger = setup_logging()

@ -3,7 +3,7 @@ import numpy as np
import pandas as pd
from scipy.integrate import simps
from utils import setup_logging
from logs import setup_logging
logger = setup_logging()

@ -5,7 +5,7 @@ After generating interim data files based on raw data, we may need to overwrite
import pandas as pd
import numpy as np
import click
from utils import setup_logging
from logs import setup_logging
logger = setup_logging()

@ -12,7 +12,7 @@ from mat4py import loadmat
from shapely.geometry import Point
from data.parse_shp import convert_coord_systems
from utils import setup_logging
from logs import setup_logging
logger = setup_logging()

@ -9,7 +9,7 @@ from shapely.geometry import LineString, Point
from shapely.geometry import shape
from shapely.ops import transform
from utils import setup_logging
from logs import setup_logging
logger = setup_logging()

@ -0,0 +1,17 @@
import logging.config
import os
import yaml
def setup_logging(path="./src/logging.yaml", default_level=logging.INFO):
"""
Setup logging configuration
"""
if os.path.exists(path):
with open(path, "rt") as f:
config = yaml.safe_load(f.read())
logging.config.dictConfig(config)
else:
logging.basicConfig(level=default_level)
return logging.getLogger(__name__)

@ -1,4 +1,3 @@
import logging.config
import os
import yaml

Loading…
Cancel
Save