Skip to content

Commit

Permalink
fix: use "extra" logging parameter instead of hijacking args
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Oct 18, 2021
1 parent a08c73b commit 5cca927
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions beet/toolchain/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
from contextlib import contextmanager
from importlib.metadata import entry_points
from typing import Any, Callable, Iterator, List, Mapping, Optional
from typing import Any, Callable, Iterator, List, Optional

import click
from click.decorators import pass_context
Expand Down Expand Up @@ -120,9 +120,6 @@ def emit(self, record: logging.LogRecord):
LogHandler.has_output = True
level = self.abbreviations.get(record.levelname, record.levelname)
style = self.style[record.levelname]
args: Mapping[str, Any] = (
record.args if isinstance(record.args, Mapping) else {}
)

line_prefix = click.style(f" |", **style)

Expand All @@ -131,14 +128,14 @@ def emit(self, record: logging.LogRecord):
leading_line = click.style(leading_line, **style)

leading_line = (
click.style(args.get("prefix", record.name), bold=True, fg="black")
click.style(getattr(record, "prefix", record.name), bold=True, fg="black")
+ " "
+ leading_line
)

echo(click.style(f"{level:<7}|", **style) + " " + leading_line)

if annotate := args.get("annotate"):
if annotate := getattr(record, "annotate", None):
lines.insert(0, click.style(str(annotate), fg="cyan"))

for line in lines:
Expand Down

0 comments on commit 5cca927

Please sign in to comment.