|
17 | 17 | ############################################################################### |
18 | 18 | # Logging |
19 | 19 |
|
| 20 | +LOG_LOGGERS = {} |
| 21 | +""" |
| 22 | +Simple method for configuring loggers that is merged into the default |
| 23 | +logging configuration. This allows for custom loggers to be configured |
| 24 | +without needing to duplicate the entire logging configuration. |
| 25 | +
|
| 26 | +Example:: |
| 27 | +
|
| 28 | + LOG_LOGGERS = { |
| 29 | + "my_package.my_module": { |
| 30 | + "level": "INFO", |
| 31 | + "handlers": ["console"] |
| 32 | + } |
| 33 | + } |
| 34 | +
|
| 35 | +""" |
| 36 | + |
| 37 | +LOG_HANDLERS = {} |
| 38 | +""" |
| 39 | +Simple method for configuring log handlers that is merged into the default |
| 40 | +logging configuration. This allows for custom handlers to be configured |
| 41 | +without needing to duplicate the entire logging configuration. |
| 42 | +
|
| 43 | +By default all handlers defined in this dict are added to the `root` |
| 44 | +handler, if this is not desired set the ``non_root`` argument to ``True``. |
| 45 | +
|
| 46 | +See the `Logging Handlers <https://docs.python.org/3/library/logging.handlers.html>`_ |
| 47 | +in the Python documentation for a complete list of builtin handlers. |
| 48 | +
|
| 49 | +Example:: |
| 50 | +
|
| 51 | + LOG_HANDLERS = { |
| 52 | + "file": { |
| 53 | + "class": "logging.handlers.RotatingFileHandler", |
| 54 | + "stream": "/path/to/my/file.log", |
| 55 | + "maxBytes": 5_242_880, # 5MiB |
| 56 | + }, |
| 57 | + "special_file": { |
| 58 | + "class": "logging.FileHandler", |
| 59 | + "non_root": True, # Don't assign to root logger |
| 60 | + "stream": "/path/to/my/special.log", |
| 61 | + } |
| 62 | + } |
| 63 | +
|
| 64 | +""" |
| 65 | + |
| 66 | + |
20 | 67 | LOGGING: Dict[str, Any] = {} |
21 | 68 | """ |
22 | 69 | Logging configuration. |
23 | 70 |
|
24 | 71 | The following configuration is applied by default:: |
25 | 72 |
|
26 | 73 | LOGGING = { |
27 | | - 'formatters': { |
28 | | - 'default': { |
29 | | - 'format': '%(asctime)s | %(levelname)s | %(name)s | %(message)s', |
| 74 | + "formatters": { |
| 75 | + "default": { |
| 76 | + "format": "%(asctime)s | %(levelname)s | %(name)s | %(message)s", |
30 | 77 | }, |
31 | 78 | }, |
32 | | - 'handlers': { |
33 | | - 'console': { |
34 | | - 'class': 'logging.StreamHandler', |
35 | | - 'formatter': 'default', |
36 | | - 'stream': 'ext://sys.stderr', |
| 79 | + "handlers": { |
| 80 | + "console": { |
| 81 | + "class": "logging.StreamHandler", |
| 82 | + "formatter": "default", |
| 83 | + "stream": "ext://sys.stderr", |
37 | 84 | }, |
38 | 85 | }, |
39 | | - 'root': { |
40 | | - # 'level' : 'INFO', # Set from command line arg parser. |
41 | | - 'handlers': ['console'], |
| 86 | + "root": { |
| 87 | + # "level" : "INFO", # Set from command line arg parser. |
| 88 | + "handlers": ["console"], |
42 | 89 | } |
43 | 90 | } |
44 | 91 |
|
|
0 commit comments