MCPcopy Create free account
hub / github.com/hynek/structlog / configure_logging

Function configure_logging

tests/test_stdlib.py:1044–1097  ·  view source on GitHub ↗

Configure logging to use ProcessorFormatter. Return a list that is filled with event dicts form calls.

(
    pre_chain,
    logger=None,
    pass_foreign_args=False,
    renderer=ConsoleRenderer(colors=False),  # noqa: B008
)

Source from the content-addressed store, hash-verified

1042
1043
1044def configure_logging(
1045 pre_chain,
1046 logger=None,
1047 pass_foreign_args=False,
1048 renderer=ConsoleRenderer(colors=False), # noqa: B008
1049):
1050 """
1051 Configure logging to use ProcessorFormatter.
1052
1053 Return a list that is filled with event dicts form calls.
1054 """
1055 event_dicts = []
1056
1057 def capture(_, __, ed):
1058 event_dicts.append(ed.copy())
1059
1060 return ed
1061
1062 logging.config.dictConfig(
1063 {
1064 "version": 1,
1065 "disable_existing_loggers": False,
1066 "formatters": {
1067 "plain": {
1068 "()": ProcessorFormatter,
1069 "processors": [
1070 capture,
1071 ProcessorFormatter.remove_processors_meta,
1072 renderer,
1073 ],
1074 "foreign_pre_chain": pre_chain,
1075 "format": "%(message)s [in %(funcName)s]",
1076 "logger": logger,
1077 "pass_foreign_args": pass_foreign_args,
1078 }
1079 },
1080 "handlers": {
1081 "default": {
1082 "level": "DEBUG",
1083 "class": "logging.StreamHandler",
1084 "formatter": "plain",
1085 }
1086 },
1087 "loggers": {
1088 "": {
1089 "handlers": ["default"],
1090 "level": "DEBUG",
1091 "propagate": True,
1092 }
1093 },
1094 }
1095 )
1096
1097 return event_dicts
1098
1099
1100@pytest.mark.usefixtures("configure_for_processor_formatter")

Calls 1

ConsoleRendererClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…