MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / instance_logger

Function instance_logger

lib/sqlalchemy/log.py:223–250  ·  view source on GitHub ↗

create a logger for an instance that implements :class:`.Identified`.

(
    instance: Identified, echoflag: _EchoFlagType = None
)

Source from the content-addressed store, hash-verified

221
222
223def instance_logger(
224 instance: Identified, echoflag: _EchoFlagType = None
225) -> None:
226 """create a logger for an instance that implements :class:`.Identified`."""
227
228 if instance.logging_name:
229 name = "%s.%s" % (
230 _qual_logger_name_for_cls(instance.__class__),
231 instance.logging_name,
232 )
233 else:
234 name = _qual_logger_name_for_cls(instance.__class__)
235
236 instance._echo = echoflag # type: ignore
237
238 logger: Union[logging.Logger, InstanceLogger]
239
240 if echoflag in (False, None):
241 # if no echo setting or False, return a Logger directly,
242 # avoiding overhead of filtering
243 logger = logging.getLogger(name)
244 else:
245 # if a specified echo flag, return an EchoLogger,
246 # which checks the flag, overrides normal log
247 # levels by calling logger._log()
248 logger = InstanceLogger(echoflag, name)
249
250 instance.logger = logger # type: ignore
251
252
253class echo_property:

Callers 1

__set__Method · 0.85

Calls 2

InstanceLoggerClass · 0.85

Tested by

no test coverage detected