Spaces:
Sleeping
Sleeping
sebaacademia
commited on
Commit
•
af19431
1
Parent(s):
bc05ff0
Upload 2 files
Browse files- __init__.py +9 -0
- constants.py +55 -0
__init__.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import logging
|
2 |
+
import logging.config
|
3 |
+
|
4 |
+
from config.constants import LOGGING_DICT_CONFIG
|
5 |
+
|
6 |
+
logging.config.dictConfig(LOGGING_DICT_CONFIG)
|
7 |
+
|
8 |
+
STREAM_LOGGER = logging.getLogger("StreamLogger")
|
9 |
+
FILE_LOGGER = logging.getLogger("FileLogger")
|
constants.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from pathlib import Path
|
3 |
+
|
4 |
+
ROOT_DIR = (Path(os.path.dirname(__file__)) / os.path.pardir).resolve()
|
5 |
+
LOGGING_DIR = (ROOT_DIR / 'config' / 'logging').resolve()
|
6 |
+
|
7 |
+
LOGGING_DICT_CONFIG = {
|
8 |
+
'version': 1,
|
9 |
+
'disable_existing_loggers': False,
|
10 |
+
'formatters': {
|
11 |
+
'simple': {
|
12 |
+
'format': '%(levelname)s: %(message)s',
|
13 |
+
},
|
14 |
+
'timestamp': {
|
15 |
+
'format': '%(asctime)s - %(levelname)s - %(message)s',
|
16 |
+
},
|
17 |
+
'with_logger': {
|
18 |
+
'format': '%(name)s - %(levelname)s - %(message)s',
|
19 |
+
},
|
20 |
+
'module_line': {
|
21 |
+
'format': '%(module)s:%(lineno)d - %(levelname)s - %(message)s',
|
22 |
+
},
|
23 |
+
'full': {
|
24 |
+
'format': '%(asctime)s - %(name)s - %(module)s:%(lineno)d - %(levelname)s - %(message)s',
|
25 |
+
},
|
26 |
+
'json': {
|
27 |
+
'format': '{"timestamp": "%(asctime)s", "logger": "%(name)s", "level": "%(levelname)s", "message": "%(message)s"}',
|
28 |
+
},
|
29 |
+
},
|
30 |
+
'handlers': {
|
31 |
+
'console': {
|
32 |
+
'level': 'DEBUG',
|
33 |
+
'class': 'logging.StreamHandler',
|
34 |
+
'formatter': 'full', # Cambia el nombre del formato aquí según sea necesario
|
35 |
+
},
|
36 |
+
'file': {
|
37 |
+
'level': 'DEBUG',
|
38 |
+
'class': 'logging.FileHandler',
|
39 |
+
'formatter': 'full', # Cambia el nombre del formato aquí según sea necesario
|
40 |
+
'filename': str((LOGGING_DIR / 'app.log').resolve()),
|
41 |
+
},
|
42 |
+
},
|
43 |
+
'loggers': {
|
44 |
+
'StreamLogger': {
|
45 |
+
'handlers': ['console'],
|
46 |
+
'level': 'DEBUG',
|
47 |
+
'propagate': False,
|
48 |
+
},
|
49 |
+
'FileLogger': {
|
50 |
+
'handlers': ['file'],
|
51 |
+
'level': 'DEBUG',
|
52 |
+
'propagate': False,
|
53 |
+
},
|
54 |
+
}
|
55 |
+
}
|