This repository was archived by the owner on Dec 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogging_setup.py
More file actions
110 lines (102 loc) · 3.15 KB
/
logging_setup.py
File metadata and controls
110 lines (102 loc) · 3.15 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"""
cardStatX - Football Card Data Ingestion System
Author: Samuel Stockstrom
License: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
"""
import logging
import logging.config
import os
LOGGING_CONFIG = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s %(name)-20s %(levelname)-8s %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S',
},
},
'handlers': {
# Handler for ingestor
'ingestor': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'DEBUG',
'formatter': 'standard',
'filename': 'logs/ingestor.log',
'backupCount': 3,
'encoding': 'utf-8',
},
# Handler for web
'web': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'DEBUG',
'formatter': 'standard',
'filename': 'logs/web.log',
'backupCount': 3,
'encoding': 'utf-8',
},
# Handler for scraper
'scraper': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'DEBUG',
'formatter': 'standard',
'filename': 'logs/scraper.log',
'backupCount': 3,
'encoding': 'utf-8',
},
# Handler for async database
'database': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'DEBUG',
'formatter': 'standard',
'filename': 'logs/database.log',
'backupCount': 3,
'encoding': 'utf-8',
},
# Handler for sync database
'sync_database': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'DEBUG',
'formatter': 'standard',
'filename': 'logs/sync_database.log',
'backupCount': 3,
'encoding': 'utf-8',
}
},
'loggers': {
# Logger for ingestor
'ingestor': {
'handlers': ['ingestor'],
'level': 'DEBUG',
'propagate': False, # avoid also sending to root
},
# Logger for web
'web': {
'handlers': ['web'],
'level': 'DEBUG',
'propagate': False, # avoid also sending to root
},
# Logger for scraper
'scraper': {
'handlers': ['scraper'],
'level': 'DEBUG',
'propagate': False, # avoid also sending to root
},
# Logger for async database
'database': {
'handlers': ['database'],
'level': 'DEBUG',
'propagate': False, # avoid also sending to root
},
# Logger for sync database
'sync_database': {
'handlers': ['sync_database'],
'level': 'DEBUG',
'propagate': False, # avoid also sending to root
}
}
}
def setup_logging():
if not os.path.isdir("logs"):
os.mkdir("logs")
logging.config.dictConfig(LOGGING_CONFIG)