-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
29 lines (23 loc) · 910 Bytes
/
__init__.py
File metadata and controls
29 lines (23 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# set up nta_app root logger
import logging
import os
from datetime import datetime
from pytz import timezone
DEPLOY_ENV = os.getenv("DEPLOY_ENV", "kube-dev")
# obtain datetime object containing the current date/time in UTC-5 (New York timezone)
def get_us_east_timestamp(*args):
return datetime.now(timezone("US/Eastern")).timetuple()
# Convert logging statement timestamp to the US/Eastern timezone.
logging.Formatter.converter = get_us_east_timestamp
logging.basicConfig(
level=logging.WARNING,
format="[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s",
datefmt="%d/%b/%Y %H:%M:%S",
)
logger = logging.getLogger("nta_app")
# set up deploy specific logging
if DEPLOY_ENV == "kube-dev": # log in dev mode
logger.setLevel(logging.INFO)
logger.warning("Init - logging in Debug mode!")
else: # log in production mode
logger.setLevel(logging.WARNING)