forked from JuneQiong/PESI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.py
31 lines (26 loc) · 689 Bytes
/
Logger.py
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
30
31
import logging
import os
import time
def create_log_dir(path, filename):
if not os.path.exists(path):
os.makedirs(path)
logger = logging.getLogger(path)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(path + filename)
fh.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(fh)
logger.addHandler(ch)
return logger
# log_path = './results/debug/logger/'
# logger = create_log_dir(log_path)
#
#
# for epoch in range(10):
# loss = epoch * 10
# mse = 1 + epoch
#
# log = 'epoch' + str(epoch) + ':\t' + 'loss' + str(loss)
#
# logger.info(log)