本文整理汇总了Python中context.Context.get_logger方法的典型用法代码示例。如果您正苦于以下问题:Python Context.get_logger方法的具体用法?Python Context.get_logger怎么用?Python Context.get_logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类context.Context
的用法示例。
在下文中一共展示了Context.get_logger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import get_logger [as 别名]
def main():
parser = argparse.ArgumentParser(description="Scraping for Oscar")
parser.add_argument(
"command", type=command_type, help="One of the following options: %s" % ", ".join(command_list()), nargs="?"
)
parser.add_argument(
"--term",
type=term_type,
help='Semester and year such as "summer 2007"' " (defaults to the latest term)",
metavar="",
)
parser.add_argument("--subject", help='Subject such as "cs" or "comp sci"', metavar="")
parser.add_argument("--number", help='Course number such as "1101" or "8803"', metavar="")
parser.add_argument(
"--course",
type=course_type,
help='Course such as "CS2110" or "psych 1101" ' "(equivalent to --subject and --number)",
metavar="",
)
parser.add_argument("--section", help='Section name such as "A" or "B"', metavar="")
parser.add_argument("--crn", help="CRN (number that identifies a section)", metavar="")
parser.add_argument(
"--offline", dest="enable_http", action="store_false", help="Disable network access and use only cached data"
)
parser.add_argument(
"--refresh",
action="store_true",
help="Fetch the most recent information from the " "server, regardless of the cache state",
)
parser.add_argument("--verbose", action="store_true", help="Print logging output")
parser.add_argument(
"--quiet",
dest="chatty",
action="store_false",
help="Do not print anything beyond the output " "requested by the command",
)
parser.add_argument(
"--log-http",
dest="log_http",
action="store_true",
help="Log HTTP requests and responses to disk " "(warning: this could include authentication credentials)",
)
args = parser.parse_args()
context = Context()
if args.chatty:
print ""
if args.verbose:
context.get_logger().addHandler(log_handler())
store = Store(context=context, enable_http=args.enable_http, log_http=args.log_http, force_refresh=args.refresh)
if args.subject is not None:
subject = store.find_subject(args.subject)
args.subject = subject
if args.command:
args.command(args, store)
if args.chatty:
print ""
示例2: main
# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import get_logger [as 别名]
def main():
parser = argparse.ArgumentParser(
description='Scraping for Oscar'
)
parser.add_argument(
'command',
type=command_type,
help='One of the following options: %s' \
% ', '.join(command_list()),
nargs='?',
)
parser.add_argument(
'--term',
type=term_type,
help='Semester and year such as "summer 2007"' \
' (defaults to the latest term)',
metavar='',
)
parser.add_argument(
'--subject',
help='Subject such as "cs" or "comp sci"',
metavar='',
)
parser.add_argument(
'--number',
help='Course number such as "1101" or "8803"',
metavar='',
)
parser.add_argument(
'--course',
type=course_type,
help='Course such as "CS2110" or "psych 1101" '
'(equivalent to --subject and --number)',
metavar='',
)
parser.add_argument(
'--section',
help='Section name such as "A" or "B"',
metavar='',
)
parser.add_argument(
'--crn',
help='CRN (number that identifies a section)',
metavar='',
)
parser.add_argument(
'--offline',
dest='enable_http',
action='store_false',
help='Disable network access and use only cached data',
)
parser.add_argument(
'--refresh',
action='store_true',
help='Fetch the most recent information from the ' \
'server, regardless of the cache state'
)
parser.add_argument(
'--verbose',
action='store_true',
help='Print logging output',
)
parser.add_argument(
'--quiet',
dest='chatty',
action='store_false',
help='Do not print anything beyond the output '
'requested by the command',
)
parser.add_argument(
'--log-http',
dest='log_http',
action='store_true',
help='Log HTTP requests and responses to disk '
'(warning: this could include authentication credentials)',
)
args = parser.parse_args()
context = Context()
if args.chatty:
print('')
if args.verbose:
context.get_logger().addHandler(log_handler())
store = Store(
#.........这里部分代码省略.........