MCPcopy
hub / github.com/Delgan/loguru / add

Method add

loguru/_logger.py:243–1018  ·  view source on GitHub ↗

r"""Add a handler sending log messages to a sink adequately configured. Parameters ---------- sink : |file-like object|_, |str|, |Path|, |callable|_, |coroutine function|_ or |Handler| An object in charge of receiving formatted logging messages and propagating th

(
        self,
        sink,
        *,
        level=_defaults.LOGURU_LEVEL,
        format=_defaults.LOGURU_FORMAT,
        filter=_defaults.LOGURU_FILTER,
        colorize=_defaults.LOGURU_COLORIZE,
        serialize=_defaults.LOGURU_SERIALIZE,
        backtrace=_defaults.LOGURU_BACKTRACE,
        diagnose=_defaults.LOGURU_DIAGNOSE,
        enqueue=_defaults.LOGURU_ENQUEUE,
        context=_defaults.LOGURU_CONTEXT,
        catch=_defaults.LOGURU_CATCH,
        **kwargs
    )

Source from the content-addressed store, hash-verified

241 return "<loguru.logger handlers=%r>" % list(self._core.handlers.values())
242
243 def add(
244 self,
245 sink,
246 *,
247 level=_defaults.LOGURU_LEVEL,
248 format=_defaults.LOGURU_FORMAT,
249 filter=_defaults.LOGURU_FILTER,
250 colorize=_defaults.LOGURU_COLORIZE,
251 serialize=_defaults.LOGURU_SERIALIZE,
252 backtrace=_defaults.LOGURU_BACKTRACE,
253 diagnose=_defaults.LOGURU_DIAGNOSE,
254 enqueue=_defaults.LOGURU_ENQUEUE,
255 context=_defaults.LOGURU_CONTEXT,
256 catch=_defaults.LOGURU_CATCH,
257 **kwargs
258 ):
259 r"""Add a handler sending log messages to a sink adequately configured.
260
261 Parameters
262 ----------
263 sink : |file-like object|_, |str|, |Path|, |callable|_, |coroutine function|_ or |Handler|
264 An object in charge of receiving formatted logging messages and propagating them to an
265 appropriate endpoint.
266 level : |int| or |str|, optional
267 The minimum severity level from which logged messages should be sent to the sink.
268 format : |str| or |callable|_, optional
269 The template used to format logged messages before being sent to the sink.
270 filter : |callable|_, |str| or |dict|, optional
271 A directive optionally used to decide for each logged message whether it should be sent
272 to the sink or not.
273 colorize : |bool|, optional
274 Whether the color markups contained in the formatted message should be converted to ansi
275 codes for terminal coloration, or stripped otherwise. If ``None``, the choice is
276 automatically made based on the sink being a tty or not.
277 serialize : |bool|, optional
278 Whether the logged message and its records should be first converted to a JSON string
279 before being sent to the sink.
280 backtrace : |bool|, optional
281 Whether the exception trace formatted should be extended upward, beyond the catching
282 point, to show the full stacktrace which generated the error.
283 diagnose : |bool|, optional
284 Whether the exception trace should display the variables values to eases the debugging.
285 This should be set to ``False`` in production to avoid leaking sensitive data.
286 enqueue : |bool|, optional
287 Whether the messages to be logged should first pass through a multiprocessing-safe queue
288 before reaching the sink. This is useful while logging to a file through multiple
289 processes. This also has the advantage of making logging calls non-blocking.
290 context : |multiprocessing.Context| or |str|, optional
291 A context object or name that will be used for all tasks involving internally the
292 |multiprocessing| module, in particular when ``enqueue=True``. If ``None``, the default
293 context is used.
294 catch : |bool|, optional
295 Whether errors occurring while sink handles logs messages should be automatically
296 caught. If ``True``, an exception message is displayed on |sys.stderr| but the exception
297 is not propagated to the caller, preventing your app to crash.
298 **kwargs
299 Additional parameters that are only valid to configure a coroutine or file sink (see
300 below).

Callers 15

configureMethod · 0.95
startMethod · 0.95
__init__.pyFile · 0.80
add_compressMethod · 0.80
create_logger_lockFunction · 0.80
create_handler_lockFunction · 0.80
writeMethod · 0.80
_format_exceptionMethod · 0.80
test_levelsFunction · 0.80
test_extraFunction · 0.80
test_patcherFunction · 0.80
test_activationFunction · 0.80

Calls 11

levelMethod · 0.95
ErrorInterceptorClass · 0.85
FileSinkClass · 0.85
StreamSinkClass · 0.85
StandardSinkClass · 0.85
AsyncSinkClass · 0.85
CallableSinkClass · 0.85
ExceptionFormatterClass · 0.85
wrapMethod · 0.80
prepare_formatMethod · 0.80
HandlerClass · 0.70

Tested by 15

test_levelsFunction · 0.64
test_extraFunction · 0.64
test_patcherFunction · 0.64
test_activationFunction · 0.64
test_diagnoseFunction · 0.64