# config0 is a standard configuration.
config0 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
# config1 adds a little to the standard configuration.
config1 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
# config2 has a subtle configuration error that should be reported
config2 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
#As config1 but with a misspelt level on a handler
config2a = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
#As config1 but with a misspelt level on a logger
config2b = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
# config3 has a less subtle configuration error
config3 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
# config4 specifies a custom formatter class to be loaded
config4 = {
+ 'version': 1,
'formatters': {
'form1' : {
'()' : __name__ + '.ExceptionFormatter',
# As config4 but using an actual callable rather than a string
config4a = {
+ 'version': 1,
'formatters': {
'form1' : {
'()' : ExceptionFormatter,
# config5 specifies a custom handler class to be loaded
config5 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
# config6 specifies a custom handler class to be loaded
# but has bad arguments
config6 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
#config 7 does not define compiler.parser but defines compiler.lexer
#so compiler.parser should be disabled after applying it
config7 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
}
config8 = {
+ 'version': 1,
'disable_existing_loggers' : False,
'formatters': {
'form1' : {
}
config9 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
}
config9a = {
+ 'version': 1,
'incremental' : True,
'handlers' : {
'hand1' : {
}
config9b = {
+ 'version': 1,
'incremental' : True,
'handlers' : {
'hand1' : {
#As config1 but with a filter added
config10 = {
+ 'version': 1,
'formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
#As config1 but using cfg:// references
config11 = {
+ 'version': 1,
+ 'true_formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handler_configs': {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'formatters' : 'cfg://true_formatters',
+ 'handlers' : {
+ 'hand1' : 'cfg://handler_configs[hand1]',
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ #As config11 but missing the version key
+ config12 = {
+ 'true_formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handler_configs': {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'formatters' : 'cfg://true_formatters',
+ 'handlers' : {
+ 'hand1' : 'cfg://handler_configs[hand1]',
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
+ #As config11 but using an unsupported version
+ config13 = {
+ 'version': 2,
'true_formatters': {
'form1' : {
'format' : '%(levelname)s ++ %(message)s',
def test_config11_ok(self):
self.test_config1_ok(self.config11)
+ def test_config12_failure(self):
+ self.assertRaises(StandardError, self.apply_config, self.config12)
+
+ def test_config13_failure(self):
+ self.assertRaises(StandardError, self.apply_config, self.config13)
+
def setup_via_listener(self, text):
port = find_unused_port()
t = logging.config.listen(port)