本文整理汇总了Python中pyutilib.misc.Options.runtime方法的典型用法代码示例。如果您正苦于以下问题:Python Options.runtime方法的具体用法?Python Options.runtime怎么用?Python Options.runtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyutilib.misc.Options
的用法示例。
在下文中一共展示了Options.runtime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_loggers
# 需要导入模块: from pyutilib.misc import Options [as 别名]
# 或者: from pyutilib.misc.Options import runtime [as 别名]
def configure_loggers(options=None, reset=False):
if reset:
options = Options()
options.runtime = Options()
options.runtime.logging = 'quiet'
logging.getLogger('pyomo.core').handlers = []
logging.getLogger('pyomo').handlers = []
logging.getLogger('pyutilib').handlers = []
#
# Configure the logger
#
if options.runtime is None:
options.runtime = Options()
if options.runtime.logging == 'quiet':
logging.getLogger('pyomo.opt').setLevel(logging.ERROR)
logging.getLogger('pyomo.core').setLevel(logging.ERROR)
logging.getLogger('pyomo').setLevel(logging.ERROR)
logging.getLogger('pyutilib').setLevel(logging.ERROR)
elif options.runtime.logging == 'warning':
logging.getLogger('pyomo.opt').setLevel(logging.WARNING)
logging.getLogger('pyomo.core').setLevel(logging.WARNING)
logging.getLogger('pyomo').setLevel(logging.WARNING)
logging.getLogger('pyutilib').setLevel(logging.WARNING)
elif options.runtime.logging == 'info':
logging.getLogger('pyomo.opt').setLevel(logging.INFO)
logging.getLogger('pyomo.core').setLevel(logging.INFO)
logging.getLogger('pyomo').setLevel(logging.INFO)
logging.getLogger('pyutilib').setLevel(logging.INFO)
elif options.runtime.logging == 'verbose':
logger.setLevel(logging.DEBUG)
logging.getLogger('pyomo').setLevel(logging.DEBUG)
logging.getLogger('pyutilib').setLevel(logging.DEBUG)
elif options.runtime.logging == 'debug':
logging.getLogger('pyomo.opt').setLevel(logging.DEBUG)
logging.getLogger('pyomo.core').setLevel(logging.DEBUG)
logging.getLogger('pyomo').setLevel(logging.DEBUG)
logging.getLogger('pyutilib').setLevel(logging.DEBUG)
if options.runtime.logfile:
logging.getLogger('pyomo.opt').handlers = []
logging.getLogger('pyomo.core').handlers = []
logging.getLogger('pyomo').handlers = []
logging.getLogger('pyutilib').handlers = []
logging.getLogger('pyomo.core').addHandler( logging.FileHandler(options.runtime.logfile, 'w'))
logging.getLogger('pyomo').addHandler( logging.FileHandler(options.runtime.logfile, 'w'))
logging.getLogger('pyutilib').addHandler( logging.FileHandler(options.runtime.logfile, 'w'))