-
Notifications
You must be signed in to change notification settings - Fork 5
/
util.py
23 lines (20 loc) · 674 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Utility functions for ocs-monkey."""
import logging
import os
import time
from typing import List
def setup_logging(log_dir: str) -> None:
"""Initializes logging to file & stdout."""
os.mkdir(log_dir)
handlers: List[logging.Handler] = [
logging.FileHandler(os.path.join(log_dir, "runner.log")),
logging.StreamHandler()
]
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logging.Formatter.converter = time.gmtime
formatter = \
logging.Formatter("%(asctime)s %(name)s - %(levelname)s - %(message)s")
for handler in handlers:
handler.setFormatter(formatter)
logger.addHandler(handler)