Skip to content

Commit be5a300

Browse files
committed
fix: setup logging
1 parent 561267b commit be5a300

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/uipath/_cli/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from uipath.functions import register_default_runtime_factory
77

8+
from .._utils._logs import setup_logging
89
from ._utils._common import add_cwd_to_path, load_environment_variables
910
from ._utils._context import CliContext
1011
from .cli_add import add as add
@@ -88,6 +89,8 @@ def cli(
8889
debug=debug,
8990
)
9091

92+
setup_logging(should_debug=debug)
93+
9194
if lv:
9295
try:
9396
version = importlib.metadata.version("uipath-langchain")

src/uipath/_utils/_logs.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@
55

66

77
def setup_logging(should_debug: Optional[bool] = None) -> None:
8-
if not logging.root.handlers and not logger.handlers:
9-
logging.basicConfig(
10-
format="%(message)s",
11-
datefmt="%Y-%m-%d %H:%M:%S",
8+
"""Configure logging for the CLI."""
9+
if not logger.handlers:
10+
handler = logging.StreamHandler()
11+
handler.setFormatter(
12+
logging.Formatter(
13+
fmt="%(message)s",
14+
datefmt="%Y-%m-%d %H:%M:%S",
15+
)
1216
)
17+
logger.addHandler(handler)
1318
logger.setLevel(logging.DEBUG if should_debug else logging.INFO)
19+
20+
# Prevent propagation to root logger to avoid duplicate logs
21+
logger.propagate = False

src/uipath/platform/_uipath.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
UiPathOpenAIService,
2727
)
2828
from .._utils._auth import resolve_config
29-
from .._utils._logs import setup_logging
3029
from .errors import BaseUrlMissingError, SecretMissingError
3130

3231

@@ -55,7 +54,6 @@ def __init__(
5554
raise BaseUrlMissingError() from e
5655
elif error["loc"][0] == "secret":
5756
raise SecretMissingError() from e
58-
setup_logging(should_debug=debug)
5957
self._execution_context = ExecutionContext()
6058

6159
@property

0 commit comments

Comments
 (0)