Temporary disable logging completely in Python -




temporary disable logging completely

i trying write new log-handler in python post json-representation of log-message http endpoint, , using request library posting. problem both request , urllib3 (used request) logs, , loggers has propagate=true, meaning logs log propagated parent loggers. if user of log-handler creates logger no name given, becomes root logger, receive messages, causing infinite loop of logging. bit lost on how fix this, , have 2 suggestions both seem brittle.

1) "reguest" , "urllib3" loggers, set propagate values false, post log message before setting propagate values old values.

2) check if incoming record has name contains ".request" or ".urllib3", , if ignore record.

both of these break badly if request library either replaces urllib3 else or changes name of logger. seems method 1 problematic in multi-threaded or multi-process case.

what want way of disabling logging current thread point , enable again after have posted message, don't know way this.

any suggestions?

importing os.devnull , setting default file handler parent logger maybe?

i flush logs devnull except explicitly set (dunno if it's or bad practice).





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

python - Minimize function with Scipy minimize -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -