-
Notifications
You must be signed in to change notification settings - Fork 4
/
logger.py
31 lines (25 loc) · 988 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
from os import fspath
from pathlib import Path
def get_logger(args):
dir = 'logs/{}/'.format(args.dataset)
Path(dir).mkdir(parents=True, exist_ok=True)
if args.search_style == "none":
if args.SC:
filename = dir + "{}_{}_SC.log".format(args.model, args.prompt_style)
else:
filename = dir + "{}_{}.log".format(args.model, args.prompt_style)
else:
filename = dir + "{}_{}_{}_{}.log".format(args.model, args.prompt_style, args.search_style, args.reward_types)
if args.checkpoint:
logging.basicConfig(filename=filename,
format='%(asctime)s %(message)s',
filemode='a')
else:
logging.basicConfig(filename=filename,
format='%(asctime)s %(message)s',
filemode='w')
# Creating an object
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
return logger