Skip to content

Commit ced3254

Browse files
getting log level from env and revoke name change for func logging config
1 parent 7198586 commit ced3254

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/eligibility_signposting_api/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
from mangum.types import LambdaContext, LambdaEvent
99

1010
from eligibility_signposting_api import repos, services
11-
from eligibility_signposting_api.config import LOG_LEVEL, config, setup_logging
11+
from eligibility_signposting_api.config import LOG_LEVEL, config, init_logging
1212
from eligibility_signposting_api.error_handler import handle_exception
1313
from eligibility_signposting_api.views.eligibility import eligibility
1414
from eligibility_signposting_api.views.hello import hello
1515

16-
setup_logging()
16+
init_logging()
1717
logger = logging.getLogger(__name__)
1818

1919
def main() -> None: # pragma: no cover

src/eligibility_signposting_api/config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from yarl import URL
66

7-
LOG_LEVEL = logging.DEBUG
7+
LOG_LEVEL = logging.getLevelNamesMapping().get(os.getenv("LOG_LEVEL", None), logging.WARNING)
88

99
AwsRegion = NewType("AwsRegion", str)
1010
AwsAccessKey = NewType("AwsAccessKey", str)
@@ -20,11 +20,10 @@ def config() -> dict[str, Any]:
2020
}
2121

2222

23-
def setup_logging():
23+
def init_logging() -> None:
2424
log_format = "%(asctime)s %(levelname)-8s %(name)s %(module)s.py:%(funcName)s():%(lineno)d %(message)s"
25-
# Define the root logger configuration
2625
logging.basicConfig(
27-
level=logging.DEBUG,
26+
level=LOG_LEVEL,
2827
format=log_format,
2928
handlers=[
3029
logging.StreamHandler()

0 commit comments

Comments
 (0)