-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.py
More file actions
72 lines (62 loc) · 1.69 KB
/
config.py
File metadata and controls
72 lines (62 loc) · 1.69 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import logging
import logging.config
import os
from pathlib import Path
from dotenv import dotenv_values
ENV = {
**dotenv_values('.env_secret'), # secret values
**dotenv_values('.env_public'),
**os.environ, # override loaded values with environment variables
}
CURRENT_DIR = Path.cwd()
LOGS_DIR = CURRENT_DIR / 'logs'
OUTPUT_DIR = CURRENT_DIR / 'output'
# kata
KATA_TEMPLATE_STR = """\
\"\"\"Kata - {name}
completed at: {completed_at:%Y-%m-%d %H:%M:%S}
by: {completed_by}
{description}
\"\"\"
{code}
"""
LOG_CONF = {
'version': 1,
'formatters': {
'file_form': {
'format': '%(asctime)s - %(levelname)-8s - %(funcName)-22s - %(message)s'
},
'console_form': {
'format': '%(levelname)-8s - %(message)s'
},
},
'handlers': {
'console_hand': {
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stdout',
'level': 'INFO',
'formatter': 'console_form',
},
'file_hand_rot': {
'class': 'logging.handlers.RotatingFileHandler',
'filename': LOGS_DIR / 'codewars_backup.log',
'maxBytes': 3_145_728, # 3MB
'backupCount': 5, # five files with log backup
'level': 'DEBUG',
'encoding': 'utf-8',
'formatter': 'file_form',
},
},
'loggers': {
'cw_logger': {
'handlers': ['console_hand', 'file_hand_rot'],
'level': 'DEBUG',
}
}
}
def setup_logging():
p = CURRENT_DIR / 'logs'
p.mkdir(parents=True, exist_ok=True)
logging.config.dictConfig(LOG_CONF)
log = logging.getLogger(__name__)
log.debug('Logging was set up.')