MCPcopy Create free account
hub / github.com/ipython/traitlets / test_logging_config

Function test_logging_config

tests/config/test_application.py:808–841  ·  view source on GitHub ↗

We should be able to configure additional log handlers.

(tmp_path, capsys)

Source from the content-addressed store, hash-verified

806
807
808def test_logging_config(tmp_path, capsys):
809 """We should be able to configure additional log handlers."""
810 log_file = tmp_path / "log_file"
811 app = Application(
812 logging_config={
813 "version": 1,
814 "handlers": {
815 "file": {
816 "class": "logging.FileHandler",
817 "level": "DEBUG",
818 "filename": str(log_file),
819 },
820 },
821 "loggers": {
822 "Application": {
823 "level": "DEBUG",
824 "handlers": ["console", "file"],
825 },
826 },
827 }
828 )
829 # the default "console" handler + our new "file" handler
830 assert len(app.log.handlers) == 2
831
832 # log a couple of messages
833 app.log.info("info")
834 app.log.warning("warn")
835
836 # test that log messages get written to the file
837 with open(log_file) as log_handle:
838 assert log_handle.read() == "info\nwarn\n"
839
840 # test that log messages get written to stderr (default console handler)
841 assert capsys.readouterr().err == "[Application] WARNING | warn\n"
842
843
844def test_get_default_logging_config_pythonw(monkeypatch):

Callers

nothing calls this directly

Calls 2

ApplicationClass · 0.90
infoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…