Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a skip-logging flag to the CLI #263

Merged
merged 1 commit into from Jan 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions dramatiq/cli.py
Expand Up @@ -171,6 +171,11 @@ def make_argument_parser():
"--log-file", type=str,
help="write all logs to a file (default: sys.stderr)",
)
parser.add_argument(
"--skip-logging",
action="store_true",
help="do not call logging.basicConfig()"
)
parser.add_argument(
"--use-spawn", action="store_true",
help="start processes by spawning (default: fork on unix, spawn on windows)"
Expand Down Expand Up @@ -249,7 +254,10 @@ def remove_pidfile(filename, logger):

def setup_parent_logging(args, *, stream=sys.stderr):
level = VERBOSITY.get(args.verbose, logging.DEBUG)
logging.basicConfig(level=level, format=LOGFORMAT, stream=stream)

if not args.skip_logging:
logging.basicConfig(level=level, format=LOGFORMAT, stream=stream)

return get_logger("dramatiq", "MainProcess")


Expand All @@ -261,9 +269,14 @@ def setup_logging(args, child_id, logging_pipe):
sys.stderr = logging_pipe

level = VERBOSITY.get(args.verbose, logging.DEBUG)
logging.basicConfig(level=level, format=LOGFORMAT, stream=logging_pipe)

if not args.skip_logging:
logging.basicConfig(level=level, format=LOGFORMAT, stream=logging_pipe)

logging.getLogger("pika").setLevel(logging.CRITICAL)

return get_logger("dramatiq", "%s(%s)" % (prefix, child_id))

return setup_logging


Expand Down