如何在Python中禁用来自第三方模块的信息日志记录

2024-09-28 22:24:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Python查询Serf集群,但是我想抑制来自Serf的INFO数据。我试图重写它,以便它只打印WARNING消息,但它拒绝接受它。在

输出:

01-04 14:57 root         INFO     Connecting to cluster
01-04 14:57 serf-rpc-client INFO     will connect to [('myhost.localdomain.local', 7373, {})]
01-04 14:57 serf-rpc-client INFO     trying to connect to myhost.localdomain.local:7373
01-04 14:57 serf-rpc-client INFO     connected to myhost.localdomain.local:7373
01-04 14:57 serf-rpc-client INFO     trying to request command: <RequestHandshake: handshake, 0, {'Version': 1}>
01-04 14:57 serf-rpc-client INFO     trying to request command: <RequestAuth: auth, 1, {'AuthKey': 'thundercats'}>
01-04 14:57 serf-rpc-client INFO     trying to request command: <RequestMembers: members, 2, {'Status': 'failed'}>
01-04 14:57 serf-rpc-client INFO     successfully handshaked
01-04 14:57 serf-rpc-client INFO     successfully authed
01-04 14:57 root         INFO     myhost123.localdomain.local has left the cluster

记录代码

^{pr2}$

Tags: toinfoclientrequestlocalconnectrootrpc