-
Couldn't load subscription status.
- Fork 16
Refactored ConsoleLogger to fix emoji handling and ensure consistency… #600
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
base: main
Are you sure you want to change the base?
Conversation
|
@cristipufu |
be5ad76 to
48c243d
Compare
src/uipath/_cli/_utils/_console.py
Outdated
| SELECT = "👇" | ||
| LINK = "🔗" | ||
| MAGIC = "✨" | ||
| INFO = "\u2139" # ℹ️ (INFORMATION SOURCE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| INFO = "\u2139" # ℹ️ (INFORMATION SOURCE) | |
| INFO = "" # (INFORMATION SOURCE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
48c243d to
e4b1582
Compare
src/uipath/_cli/_utils/_console.py
Outdated
| if fg: | ||
| formatted_message = f"{emoji} {click.style(message, fg=fg)}" if emoji else click.style(message, fg=fg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can simplify the logic here:
| if fg: | |
| formatted_message = f"{emoji} {click.style(message, fg=fg)}" if emoji else click.style(message, fg=fg) | |
| formatted_message = f"{level.value} " if level.value else "" | |
| formatted_message += click.style(message, fg=fg) if fg else message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. updated formatted_message logic as per your suggestion. Thanks @radu-mocanu !
e4b1582 to
f9afdda
Compare
f9afdda to
3a6b753
Compare
|
almost done 👍 |
- Updated all ConsoleLogger convenience methods to pass Enum members instead of .value - Fixed log() to extract emoji with level.value internally, maintaining type-safety - Ensured error messages use level == LogLevel.ERROR for stderr - Made evaluation progress methods consistent with LogLevel Unicode symbols - Overall: logging and progress updates now reliably display intended Unicode symbols ->latest change: - Updated ConsoleLogger.error() to use click.get_current_context().exit when available and fallback to builtins.exit for reliable behavior - Ensures proper exit in CLI context while remaining testable with mocks - Retains previous logging improvements: Unicode symbols, LogLevel consistency, and type-safety - Simplified formatted_message logic and cleaned up internal log handling - Updated "info" Unicode to empty string for consistent output - Added test_console.py coverage for error() exit behavior: * Mocked ctx.exit to verify proper invocation * Ensures builtins.exit fallback works in test scenarios - Overall: error logging and exit mechanism now robust, consistent, and fully tested
3a6b753 to
6a49dce
Compare
|
@radu-mocanu, Thanks for the feedback. I’ve addressed the failing tests and added unit tests in test_console.py for ConsoleLogger, ensuring proper behavior for error() with ctx.exit and fallback to builtins.exit. All tests are passing successfully, confirming the logger’s functionality. Please let me know if you need any further verification or tweaks! |
… with LogLevel Enum: