Skip to content

Commit 2439933

Browse files
committed
Check for an active click context in log filter
1 parent a4c053d commit 2439933

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/labels/log.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ class ContextFilter(logging.Filter):
77
"""Logging filter to add the click command to the record."""
88

99
def filter(self, record: logging.LogRecord) -> bool:
10-
ctx = click.get_current_context()
10+
ctx = click.get_current_context(silent=True)
11+
if not ctx:
12+
return False
13+
1114
setattr(record, "cmd", ctx.command.name)
1215
return True
1316

0 commit comments

Comments
 (0)