Skip to content

Commit f01028d

Browse files
committed
Add support for setting log level using FOMULATE_LOG_LEVEL
1 parent d60ddd1 commit f01028d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

formulate/logging.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
from __future__ import print_function
55

66
from functools import wraps
7-
import string
87
import logging
8+
import os
99
import random
10+
import string
1011

1112

1213
__all__ = [
@@ -78,4 +79,15 @@ def new_func(*args, **kwargs):
7879
logger = logging.getLogger(LOGGER_NAME)
7980

8081

81-
logger.setLevel(logging.WARN)
82+
try:
83+
logger.setLevel({
84+
'CRITICAL': logging.CRITICAL,
85+
'FATAL': logging.CRITICAL,
86+
'ERROR': logging.ERROR,
87+
'WARNING': logging.WARNING,
88+
'WARN': logging.WARNING,
89+
'INFO': logging.INFO,
90+
'DEBUG': logging.DEBUG,
91+
}[os.environ['FOMULATE_LOG_LEVEL'].upper()])
92+
except KeyError:
93+
logger.setLevel(logging.WARNING)

0 commit comments

Comments
 (0)