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 @@ -768,18 +768,20 @@ def configure_handler(self, config):
768
768
klass = cname
769
769
else :
770
770
klass = self .resolve (cname )
771
- if issubclass (klass , logging .handlers .MemoryHandler ) and \
772
- 'target' in config :
773
- # Special case for handler which refers to another handler
774
- try :
775
- tn = config ['target' ]
776
- th = self .config ['handlers' ][tn ]
777
- if not isinstance (th , logging .Handler ):
778
- config .update (config_copy ) # restore for deferred cfg
779
- raise TypeError ('target not configured yet' )
780
- config ['target' ] = th
781
- except Exception as e :
782
- raise ValueError ('Unable to set target handler %r' % tn ) from e
771
+ if issubclass (klass , logging .handlers .MemoryHandler ):
772
+ if 'flushLevel' in config :
773
+ config ['flushLevel' ] = logging ._checkLevel (config ['flushLevel' ])
774
+ if 'target' in config :
775
+ # Special case for handler which refers to another handler
776
+ try :
777
+ tn = config ['target' ]
778
+ th = self .config ['handlers' ][tn ]
779
+ if not isinstance (th , logging .Handler ):
780
+ config .update (config_copy ) # restore for deferred cfg
781
+ raise TypeError ('target not configured yet' )
782
+ config ['target' ] = th
783
+ except Exception as e :
784
+ raise ValueError ('Unable to set target handler %r' % tn ) from e
783
785
elif issubclass (klass , logging .handlers .QueueHandler ):
784
786
# Another special case for handler which refers to other handlers
785
787
# if 'handlers' not in config:
Original file line number Diff line number Diff line change @@ -3050,6 +3050,30 @@ def format(self, record):
3050
3050
},
3051
3051
}
3052
3052
3053
+ config18 = {
3054
+ "version" : 1 ,
3055
+ "handlers" : {
3056
+ "console" : {
3057
+ "class" : "logging.StreamHandler" ,
3058
+ "level" : "DEBUG" ,
3059
+ },
3060
+ "buffering" : {
3061
+ "class" : "logging.handlers.MemoryHandler" ,
3062
+ "capacity" : 5 ,
3063
+ "target" : "console" ,
3064
+ "level" : "DEBUG" ,
3065
+ "flushLevel" : "ERROR"
3066
+ }
3067
+ },
3068
+ "loggers" : {
3069
+ "mymodule" : {
3070
+ "level" : "DEBUG" ,
3071
+ "handlers" : ["buffering" ],
3072
+ "propagate" : "true"
3073
+ }
3074
+ }
3075
+ }
3076
+
3053
3077
bad_format = {
3054
3078
"version" : 1 ,
3055
3079
"formatters" : {
@@ -3536,6 +3560,11 @@ def test_config17_ok(self):
3536
3560
h = logging ._handlers ['hand1' ]
3537
3561
self .assertEqual (h .formatter .custom_property , 'value' )
3538
3562
3563
+ def test_config18_ok (self ):
3564
+ self .apply_config (self .config18 )
3565
+ handler = logging .getLogger ('mymodule' ).handlers [0 ]
3566
+ self .assertEqual (handler .flushLevel , logging .ERROR )
3567
+
3539
3568
def setup_via_listener (self , text , verify = None ):
3540
3569
text = text .encode ("utf-8" )
3541
3570
# Ask for a randomly assigned port (by using port 0)
You can’t perform that action at this time.
0 commit comments