本文整理汇总了Python中daiquiri.setup方法的典型用法代码示例。如果您正苦于以下问题:Python daiquiri.setup方法的具体用法?Python daiquiri.setup怎么用?Python daiquiri.setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类daiquiri
的用法示例。
在下文中一共展示了daiquiri.setup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_logger
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def setup_logger(logger_dir, name="logger"):
os.environ['TZ'] = 'Africa/Johannesburg'
time.tzset()
daiquiri_formatter = daiquiri.formatter.ColorFormatter(
fmt= "%(asctime)s %(color)s%(levelname)s: %(message)s%(color_stop)s",
datefmt="%Y-%m-%d %H:%M:%S")
logger_path = os.path.join(logger_dir, name)
daiquiri.setup(level=logging.INFO, outputs=(
daiquiri.output.Stream(formatter=daiquiri_formatter),
daiquiri.output.File(logger_path,formatter=daiquiri_formatter),
))
# To access the logger from other files, just put this line at the top:
# logger = daiquiri.getLogger(__name__)
#------------------------------------------------------------------------------
# LOAD OR SAVE HYPERPARAMETERS
#------------------------------------------------------------------------------
示例2: setup_logging
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def setup_logging(args):
log_level = "WARN"
if args.verbosity > 0:
log_level = "INFO"
if args.verbosity > 1:
log_level = "DEBUG"
if args.log_section is None:
daiquiri.setup(level=log_level)
else:
daiquiri.setup(level="WARN")
logger = logging.getLogger(args.log_section)
logger.setLevel(log_level)
示例3: setup_logging
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def setup_logging():
outputs = []
if config.LOG_STDOUT:
outputs.append(
daiquiri.output.Stream(sys.stdout, level=config.LOG_STDOUT_LEVEL,)
)
if config.LOG_DATADOG:
outputs.append(daiquiri.output.Datadog(level=config.LOG_DATADOG_LEVEL))
daiquiri.setup(
outputs=outputs, level=config.LOG_LEVEL,
)
daiquiri.set_default_log_levels(
[
("github.Requester", "WARN"),
("urllib3.connectionpool", "WARN"),
("urllib3.util.retry", "WARN"),
("vcr", "WARN"),
("httpx", "WARN"),
("asyncio", "WARN"),
("uvicorn.access", "WARN"),
]
)
config_log()
示例4: main
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def main(ctx, verbose=False, debug=False, log_file=None,
env_prefix=None, global_urls_variable=None):
formatter = daiquiri.formatter.ColorFormatter(
fmt="%(color)s%(levelname)s "
"[%(name)s] %(message)s%(color_stop)s")
outputs = [
daiquiri.output.Stream(sys.stderr, formatter=formatter)
]
if log_file:
outputs.append(daiquiri.output.File(log_file,
formatter=formatter))
ctx.obj = {
"debug": debug,
}
if env_prefix is not None:
ctx.obj['env_prefix'] = env_prefix
if global_urls_variable is not None:
ctx.obj['global_urls_variable'] = global_urls_variable
if debug:
level = logging.DEBUG
elif verbose:
level = logging.INFO
else:
level = logging.WARNING
daiquiri.setup(outputs=outputs, level=level)
示例5: test_setup
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def test_setup(self):
daiquiri.setup()
daiquiri.setup(level=logging.DEBUG)
daiquiri.setup(program_name="foobar")
示例6: test_setup_json_formatter
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def test_setup_json_formatter(self):
stream = six.moves.StringIO()
daiquiri.setup(outputs=(
daiquiri.output.Stream(
stream, formatter=daiquiri.formatter.JSON_FORMATTER),
))
daiquiri.getLogger(__name__).warning("foobar")
self.assertEqual({"message": "foobar"},
json.loads(stream.getvalue()))
示例7: test_setup_json_formatter_with_extras
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def test_setup_json_formatter_with_extras(self):
stream = six.moves.StringIO()
daiquiri.setup(outputs=(
daiquiri.output.Stream(
stream, formatter=daiquiri.formatter.JSON_FORMATTER),
))
daiquiri.getLogger(__name__).warning("foobar", foo="bar")
self.assertEqual({"message": "foobar", "foo": "bar"},
json.loads(stream.getvalue()))
示例8: test_capture_warnings
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def test_capture_warnings(self):
stream = six.moves.StringIO()
daiquiri.setup(outputs=(
daiquiri.output.Stream(stream),
))
warnings.warn("omg!")
line = stream.getvalue()
self.assertIn("WARNING py.warnings: ", line)
self.assertIn("daiquiri/tests/test_daiquiri.py:62: "
"UserWarning: omg!\n warnings.warn(\"omg!\")\n",
line)
示例9: test_no_capture_warnings
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def test_no_capture_warnings(self):
stream = six.moves.StringIO()
daiquiri.setup(outputs=(
daiquiri.output.Stream(stream),
), capture_warnings=False)
warnings.warn("omg!")
self.assertEqual("", stream.getvalue())
示例10: test_extra_with_two_loggers
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def test_extra_with_two_loggers():
stream = six.moves.StringIO()
daiquiri.setup(outputs=(
daiquiri.output.Stream(stream),
))
log1 = daiquiri.getLogger("foobar")
log1.error("argh")
log2 = daiquiri.getLogger("foobar", key="value")
log2.warning("boo")
lines = stream.getvalue().strip().split("\n")
assert lines[0].endswith("ERROR foobar: argh")
assert lines[1].endswith("WARNING foobar [key: value]: boo")
示例11: test_datadog
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def test_datadog(self):
with mock.patch('socket.socket') as mock_socket:
socket_instance = mock_socket.return_value
daiquiri.setup(outputs=(daiquiri.output.Datadog(),),
level=logging.DEBUG)
logger = daiquiri.getLogger()
logger.error("foo", bar=1)
logger.info("bar")
try:
1 / 0
except ZeroDivisionError:
logger = daiquiri.getLogger("saymyname")
logger.error("backtrace", exc_info=True)
socket_instance.connect.assert_called_once_with(
("127.0.0.1", 10518)
)
socket_instance.sendall.assert_has_calls([
mock.call(DatadogMatcher({
"status": "error", "message": "foo", "bar": 1,
"logger": {"name": "root"}, "timestamp": mock.ANY,
})),
mock.call(DatadogMatcher({
"status": "info", "message": "bar",
"logger": {"name": "root"}, "timestamp": mock.ANY,
})),
mock.call(DatadogMatcher({
"status": "error", "message": "backtrace",
"logger": {"name": "saymyname"}, "timestamp": mock.ANY,
"error": {"kind": "ZeroDivisionError", "stack": None,
"message": mock.ANY}
})),
])
示例12: logging_info_example
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def logging_info_example():
daiquiri.setup(level="INFO")
msprime.simulate(10, Ne=1000, model=["dtwf", (100, "hudson")])
示例13: logging_debug_example
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def logging_debug_example():
daiquiri.setup(level="DEBUG")
msprime.simulate(
10 ** 5, Ne=10000, recombination_rate=2e-8, length=1e6, random_seed=32
)
示例14: setup_logging
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def setup_logging(args):
log_level = "WARN"
if args.verbose == 1:
log_level = "INFO"
elif args.verbose >= 2:
log_level = "DEBUG"
daiquiri.setup(level=log_level)
msprime_logger = daiquiri.getLogger("msprime")
msprime_logger.setLevel("WARN")
示例15: main
# 需要导入模块: import daiquiri [as 别名]
# 或者: from daiquiri import setup [as 别名]
def main():
args = build_parser().parse_args()
daiquiri.setup(
outputs=(
daiquiri.output.Stream(
sys.stdout,
formatter=daiquiri.formatter.ColorFormatter(
fmt="%(color)s%(message)s%(color_stop)s"
),
),
),
level=logging.DEBUG if args.debug else logging.INFO,
)
try:
return git_pull_request(
target_remote=args.target_remote,
target_branch=args.target_branch,
title=args.title,
message=args.message,
keep_message=args.keep_message,
comment=args.comment,
rebase=not args.no_rebase,
download=args.download,
download_setup=args.download_setup,
fork=args.fork,
setup_only=args.setup_only,
branch_prefix=args.branch_prefix,
dry_run=args.dry_run,
labels=args.label,
)
except Exception:
LOG.error("Unable to send pull request", exc_info=True)
return 128