Skip to content

Commit 7a6b8af

Browse files
committed
feat(cli): introduce a command line switch to log to a file
1 parent 857db22 commit 7a6b8af

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/robotcode/cli/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@
8888
show_default=True,
8989
show_envvar=True,
9090
)
91+
@click.option(
92+
"--log-filename",
93+
type=click.Path(file_okay=True, dir_okay=False, writable=True, exists=False, path_type=str),
94+
help="Write log output to a file instead to console.",
95+
default=None,
96+
show_default=True,
97+
show_envvar=True,
98+
)
9199
@click.option(
92100
"--log-calls",
93101
is_flag=True,
@@ -146,6 +154,7 @@ def robotcode(
146154
pager: Optional[bool],
147155
log: bool,
148156
log_level: str,
157+
log_filename: Optional[str],
149158
log_calls: bool,
150159
default_path: Optional[List[str]],
151160
launcher_script: Optional[str] = None,
@@ -186,7 +195,7 @@ def robotcode(
186195
if log_calls:
187196
LoggingDescriptor.set_call_tracing(True)
188197

189-
logging.basicConfig(level=log_level, format="%(name)s:%(levelname)s: %(message)s")
198+
logging.basicConfig(level=log_level, format="%(name)s:%(levelname)s: %(message)s", filename=log_filename)
190199

191200
if debugpy:
192201
from robotcode.core.utils.debugpy import start_debugpy, wait_for_debugpy_connected

0 commit comments

Comments
 (0)