Return the base logging configuration. The default is to log to stderr using a StreamHandler, if no default handler already exists. The log handler level starts at logging.WARN, but this can be adjusted by setting the ``log_level`` attribute. The ``logging_
(self)
| 225 | ).tag(config=True) |
| 226 | |
| 227 | def get_default_logging_config(self) -> StrDict: |
| 228 | """Return the base logging configuration. |
| 229 | |
| 230 | The default is to log to stderr using a StreamHandler, if no default |
| 231 | handler already exists. |
| 232 | |
| 233 | The log handler level starts at logging.WARN, but this can be adjusted |
| 234 | by setting the ``log_level`` attribute. |
| 235 | |
| 236 | The ``logging_config`` trait is merged into this allowing for finer |
| 237 | control of logging. |
| 238 | |
| 239 | """ |
| 240 | config: StrDict = { |
| 241 | "version": 1, |
| 242 | "handlers": { |
| 243 | "console": { |
| 244 | "class": "logging.StreamHandler", |
| 245 | "formatter": "console", |
| 246 | "level": logging.getLevelName(self.log_level), # type:ignore[arg-type] |
| 247 | "stream": "ext://sys.stderr", |
| 248 | }, |
| 249 | }, |
| 250 | "formatters": { |
| 251 | "console": { |
| 252 | "class": ( |
| 253 | f"{self._log_formatter_cls.__module__}" |
| 254 | f".{self._log_formatter_cls.__name__}" |
| 255 | ), |
| 256 | "format": self.log_format, |
| 257 | "datefmt": self.log_datefmt, |
| 258 | }, |
| 259 | }, |
| 260 | "loggers": { |
| 261 | self.__class__.__name__: { |
| 262 | "level": "DEBUG", |
| 263 | "handlers": ["console"], |
| 264 | } |
| 265 | }, |
| 266 | "disable_existing_loggers": False, |
| 267 | } |
| 268 | |
| 269 | if IS_PYTHONW: |
| 270 | # disable logging |
| 271 | # (this should really go to a file, but file-logging is only |
| 272 | # hooked up in parallel applications) |
| 273 | del config["handlers"] |
| 274 | del config["loggers"] |
| 275 | |
| 276 | return config |
| 277 | |
| 278 | @observe("log_datefmt", "log_format", "log_level", "logging_config") |
| 279 | def _observe_logging_change(self, change: Bunch) -> None: |
no outgoing calls