File tree Expand file tree Collapse file tree 2 files changed +43
-12
lines changed Expand file tree Collapse file tree 2 files changed +43
-12
lines changed Original file line number Diff line number Diff line change @@ -761,18 +761,20 @@ def configure_handler(self, config):
761
761
klass = cname
762
762
else :
763
763
klass = self .resolve (cname )
764
- if issubclass (klass , logging .handlers .MemoryHandler ) and \
765
- 'target' in config :
766
- # Special case for handler which refers to another handler
767
- try :
768
- tn = config ['target' ]
769
- th = self .config ['handlers' ][tn ]
770
- if not isinstance (th , logging .Handler ):
771
- config .update (config_copy ) # restore for deferred cfg
772
- raise TypeError ('target not configured yet' )
773
- config ['target' ] = th
774
- except Exception as e :
775
- raise ValueError ('Unable to set target handler %r' % tn ) from e
764
+ if issubclass (klass , logging .handlers .MemoryHandler ):
765
+ if 'flushLevel' in config :
766
+ config ['flushLevel' ] = logging ._checkLevel (config ['flushLevel' ])
767
+ if 'target' in config :
768
+ # Special case for handler which refers to another handler
769
+ try :
770
+ tn = config ['target' ]
771
+ th = self .config ['handlers' ][tn ]
772
+ if not isinstance (th , logging .Handler ):
773
+ config .update (config_copy ) # restore for deferred cfg
774
+ raise TypeError ('target not configured yet' )
775
+ config ['target' ] = th
776
+ except Exception as e :
777
+ raise ValueError ('Unable to set target handler %r' % tn ) from e
776
778
elif issubclass (klass , logging .handlers .QueueHandler ):
777
779
# Another special case for handler which refers to other handlers
778
780
# if 'handlers' not in config:
Original file line number Diff line number Diff line change @@ -3036,6 +3036,30 @@ def format(self, record):
3036
3036
},
3037
3037
}
3038
3038
3039
+ config18 = {
3040
+ "version" : 1 ,
3041
+ "handlers" : {
3042
+ "console" : {
3043
+ "class" : "logging.StreamHandler" ,
3044
+ "level" : "DEBUG" ,
3045
+ },
3046
+ "buffering" : {
3047
+ "class" : "logging.handlers.MemoryHandler" ,
3048
+ "capacity" : 5 ,
3049
+ "target" : "console" ,
3050
+ "level" : "DEBUG" ,
3051
+ "flushLevel" : "ERROR"
3052
+ }
3053
+ },
3054
+ "loggers" : {
3055
+ "mymodule" : {
3056
+ "level" : "DEBUG" ,
3057
+ "handlers" : ["buffering" ],
3058
+ "propagate" : "true"
3059
+ }
3060
+ }
3061
+ }
3062
+
3039
3063
bad_format = {
3040
3064
"version" : 1 ,
3041
3065
"formatters" : {
@@ -3522,6 +3546,11 @@ def test_config17_ok(self):
3522
3546
h = logging ._handlers ['hand1' ]
3523
3547
self .assertEqual (h .formatter .custom_property , 'value' )
3524
3548
3549
+ def test_config18_ok (self ):
3550
+ self .apply_config (self .config18 )
3551
+ handler = logging .getLogger ('mymodule' ).handlers [0 ]
3552
+ self .assertEqual (handler .flushLevel , logging .ERROR )
3553
+
3525
3554
def setup_via_listener (self , text , verify = None ):
3526
3555
text = text .encode ("utf-8" )
3527
3556
# Ask for a randomly assigned port (by using port 0)
You can’t perform that action at this time.
0 commit comments