2424Server specific configuration options are handled in server.py
2525"""
2626
27+ import logging
2728from builtins import super
2829from collections import namedtuple
2930from enum import IntEnum , Enum , unique
3031
31- import logbook
32-
3332import nio
3433from matrix .globals import SCRIPT_NAME , SERVERS , W
3534from matrix .utf import utf8_decode
@@ -57,9 +56,8 @@ class NewChannelPosition(IntEnum):
5756 NEXT = 1
5857 NEAR_SERVER = 2
5958
60-
61- nio .logger_group .level = logbook .ERROR
62-
59+ nio_logger = logging .getLogger ("nio" )
60+ nio_logger .setLevel (logging .ERROR )
6361
6462class Option (
6563 namedtuple (
@@ -141,18 +139,13 @@ def change_log_level(category, level):
141139 Called every time the user changes the log level or log category
142140 configuration option."""
143141
142+ if category == "encryption" :
143+ category = "crypto"
144+
144145 if category == "all" :
145- nio .logger_group .level = level
146- elif category == "http" :
147- nio .http .logger .level = level
148- elif category == "client" :
149- nio .client .logger .level = level
150- elif category == "events" :
151- nio .events .logger .level = level
152- elif category == "responses" :
153- nio .responses .logger .level = level
154- elif category == "encryption" :
155- nio .crypto .logger .level = level
146+ nio_logger .setLevel (level )
147+ else :
148+ nio_logger .getChild (category ).setLevel (level )
156149
157150
158151@utf8_decode
@@ -178,7 +171,7 @@ def config_log_level_cb(data, option):
178171@utf8_decode
179172def config_log_category_cb (data , option ):
180173 """Callback for the network.debug_category option."""
181- change_log_level (G .CONFIG .debug_category , logbook .ERROR )
174+ change_log_level (G .CONFIG .debug_category , logging .ERROR )
182175 G .CONFIG .debug_category = G .CONFIG .network .debug_category
183176 change_log_level (
184177 G .CONFIG .network .debug_category , G .CONFIG .network .debug_level
@@ -203,20 +196,20 @@ def config_pgup_cb(data, option):
203196 return 1
204197
205198
206- def level_to_logbook (value ):
199+ def level_to_logging (value ):
207200 if value == 0 :
208- return logbook .ERROR
201+ return logging .ERROR
209202 if value == 1 :
210- return logbook .WARNING
203+ return logging .WARNING
211204 if value == 2 :
212- return logbook .INFO
205+ return logging .INFO
213206 if value == 3 :
214- return logbook .DEBUG
207+ return logging .DEBUG
215208
216- return logbook .ERROR
209+ return logging .ERROR
217210
218211
219- def logbook_category (value ):
212+ def logging_category (value ):
220213 if value == 0 :
221214 return "all"
222215 if value == 1 :
@@ -647,7 +640,7 @@ def __init__(self):
647640 0 ,
648641 "error" ,
649642 "Enable network protocol debugging." ,
650- level_to_logbook ,
643+ level_to_logging ,
651644 config_log_level_cb ,
652645 ),
653646 Option (
@@ -658,7 +651,7 @@ def __init__(self):
658651 0 ,
659652 "all" ,
660653 "Debugging category" ,
661- logbook_category ,
654+ logging_category ,
662655 config_log_category_cb ,
663656 ),
664657 Option (
0 commit comments