本文整理汇总了Python中saml2.config.SPConfig.setup_logger方法的典型用法代码示例。如果您正苦于以下问题:Python SPConfig.setup_logger方法的具体用法?Python SPConfig.setup_logger怎么用?Python SPConfig.setup_logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类saml2.config.SPConfig
的用法示例。
在下文中一共展示了SPConfig.setup_logger方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_conf_syslog
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import setup_logger [as 别名]
def test_conf_syslog():
c = SPConfig().load_file("server_conf_syslog")
c.context = "sp"
# otherwise the logger setting is not changed
root_logger.level = logging.NOTSET
root_logger.handlers = []
print c.logger
c.setup_logger()
assert root_logger.level != logging.NOTSET
assert root_logger.level == logging.INFO
assert len(root_logger.handlers) == 1
assert isinstance(root_logger.handlers[0],
logging.handlers.SysLogHandler)
handler = root_logger.handlers[0]
print handler.__dict__
assert handler.facility == "local3"
assert handler.address == ('localhost', 514)
if sys.version >= (2, 7):
assert handler.socktype == 2
else:
pass
assert root_logger.name == "saml2"
assert root_logger.level == 20
示例2: test_wayf
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import setup_logger [as 别名]
def test_wayf():
c = SPConfig().load_file("server_conf")
c.context = "sp"
idps = c.metadata.with_descriptor("idpsso")
ent = idps.values()[0]
assert name(ent) == 'Example Co.'
assert name(ent, "se") == 'Exempel AB'
c.setup_logger()
assert root_logger.level != logging.NOTSET
assert root_logger.level == logging.INFO
assert len(root_logger.handlers) == 1
assert isinstance(root_logger.handlers[0],
logging.handlers.RotatingFileHandler)
handler = root_logger.handlers[0]
assert handler.backupCount == 5
try:
assert handler.maxBytes == 100000
except AssertionError:
assert handler.maxBytes == 500000
assert handler.mode == "a"
assert root_logger.name == "saml2"
assert root_logger.level == 20
示例3: test_conf_syslog
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import setup_logger [as 别名]
def test_conf_syslog():
c = SPConfig().load_file("server_conf_syslog")
c.context = "sp"
# otherwise the logger setting is not changed
root_logger.level = logging.NOTSET
while root_logger.handlers:
handler = root_logger.handlers[-1]
root_logger.removeHandler(handler)
handler.flush()
handler.close()
print(c.logger)
c.setup_logger()
assert root_logger.level != logging.NOTSET
assert root_logger.level == logging.INFO
assert len(root_logger.handlers) == 1
assert isinstance(root_logger.handlers[0],
logging.handlers.SysLogHandler)
handler = root_logger.handlers[0]
print(handler.__dict__)
assert handler.facility == "local3"
assert handler.address == ('localhost', 514)
if ((sys.version_info.major == 2 and sys.version_info.minor >= 7) or
sys.version_info.major > 2):
assert handler.socktype == 2
else:
pass
assert root_logger.name == "saml2"
assert root_logger.level == 20
示例4: test_wayf
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import setup_logger [as 别名]
def test_wayf():
c = SPConfig().load_file("server_conf")
c.context = "sp"
idps = c.idps()
assert idps == {'urn:mace:example.com:saml:roland:idp': 'Example Co.'}
idps = c.idps(["se","en"])
assert idps == {'urn:mace:example.com:saml:roland:idp': 'Exempel AB'}
c.setup_logger()
assert root_logger.level != logging.NOTSET
assert root_logger.level == logging.INFO
assert len(root_logger.handlers) == 1
assert isinstance(root_logger.handlers[0],
logging.handlers.RotatingFileHandler)
handler = root_logger.handlers[0]
assert handler.backupCount == 5
assert handler.maxBytes == 100000
assert handler.mode == "a"
assert root_logger.name == "saml2"
assert root_logger.level == 20