Python daiquiri.setup() Examples
The following are 16
code examples of daiquiri.setup().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
daiquiri
, or try the search function
.
Example #1
Source File: config.py From matrix-capsules-with-em-routing with Apache License 2.0 | 6 votes |
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 #------------------------------------------------------------------------------
Example #2
Source File: evaluation.py From tsinfer with GNU General Public License v3.0 | 5 votes |
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)
Example #3
Source File: cli.py From tsinfer with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: logs.py From mergify-engine with Apache License 2.0 | 5 votes |
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()
Example #5
Source File: __main__.py From pifpaf with Apache License 2.0 | 5 votes |
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)
Example #6
Source File: test_daiquiri.py From daiquiri with Apache License 2.0 | 5 votes |
def test_setup(self): daiquiri.setup() daiquiri.setup(level=logging.DEBUG) daiquiri.setup(program_name="foobar")
Example #7
Source File: test_daiquiri.py From daiquiri with Apache License 2.0 | 5 votes |
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()))
Example #8
Source File: test_daiquiri.py From daiquiri with Apache License 2.0 | 5 votes |
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()))
Example #9
Source File: test_daiquiri.py From daiquiri with Apache License 2.0 | 5 votes |
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)
Example #10
Source File: test_daiquiri.py From daiquiri with Apache License 2.0 | 5 votes |
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())
Example #11
Source File: test_daiquiri.py From daiquiri with Apache License 2.0 | 5 votes |
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")
Example #12
Source File: test_output.py From daiquiri with Apache License 2.0 | 5 votes |
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} })), ])
Example #13
Source File: logging_info.py From msprime with GNU General Public License v3.0 | 5 votes |
def logging_info_example(): daiquiri.setup(level="INFO") msprime.simulate(10, Ne=1000, model=["dtwf", (100, "hudson")])
Example #14
Source File: logging_debug.py From msprime with GNU General Public License v3.0 | 5 votes |
def logging_debug_example(): daiquiri.setup(level="DEBUG") msprime.simulate( 10 ** 5, Ne=10000, recombination_rate=2e-8, length=1e6, random_seed=32 )
Example #15
Source File: verification.py From msprime with GNU General Public License v3.0 | 5 votes |
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")
Example #16
Source File: __init__.py From git-pull-request with Apache License 2.0 | 5 votes |
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