@@ -388,10 +388,12 @@ def usesTime(self):
388388 def format (self , record ):
389389 return self ._tpl .substitute (** record .__dict__ )
390390
391+ BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s"
392+
391393_STYLES = {
392- '%' : PercentStyle ,
393- '{' : StrFormatStyle ,
394- '$' : StringTemplateStyle
394+ '%' : ( PercentStyle , BASIC_FORMAT ) ,
395+ '{' : ( StrFormatStyle , '{levelname}:{name}:{message}' ) ,
396+ '$' : ( StringTemplateStyle , '${levelname}:${name}:${message}' ),
395397}
396398
397399class Formatter (object ):
@@ -456,7 +458,7 @@ def __init__(self, fmt=None, datefmt=None, style='%'):
456458 if style not in _STYLES :
457459 raise ValueError ('Style must be one of: %s' % ',' .join (
458460 _STYLES .keys ()))
459- self ._style = _STYLES [style ](fmt )
461+ self ._style = _STYLES [style ][ 0 ] (fmt )
460462 self ._fmt = self ._style ._fmt
461463 self .datefmt = datefmt
462464
@@ -1629,8 +1631,6 @@ def hasHandlers(self):
16291631# Configuration classes and functions
16301632#---------------------------------------------------------------------------
16311633
1632- BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s"
1633-
16341634def basicConfig (** kwargs ):
16351635 """
16361636 Do basic configuration for the logging system.
@@ -1704,9 +1704,12 @@ def basicConfig(**kwargs):
17041704 stream = kwargs .get ("stream" )
17051705 h = StreamHandler (stream )
17061706 handlers = [h ]
1707- fs = kwargs .get ("format" , BASIC_FORMAT )
17081707 dfs = kwargs .get ("datefmt" , None )
17091708 style = kwargs .get ("style" , '%' )
1709+ if style not in _STYLES :
1710+ raise ValueError ('Style must be one of: %s' % ',' .join (
1711+ _STYLES .keys ()))
1712+ fs = kwargs .get ("format" , _STYLES [style ][1 ])
17101713 fmt = Formatter (fs , dfs , style )
17111714 for h in handlers :
17121715 if h .formatter is None :
0 commit comments