Restore clean console output in ConsoleReferenceServer and ConsoleReferenceClient #3409
+65
−102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
ConsoleReferenceServer and ConsoleReferenceClient were displaying user-facing messages through the logger, causing timestamped output like
[17:12:44 INF] Start the server.instead of clean console output. In Debug mode, this also required--consoleand--logparameters to avoid NullLogger exceptions.Changes:
logger.LogInformation()withConsole.WriteLine()for all user-facing messages in:Program.csfiles (server/client startup, configuration, errors)UAServer.cs(endpoint display)UAClient.cs(connection/session messages)ClientSamples.cs(read/write/browse/method call outputs)ConsoleTelemetryinitialization and passing to library methods (no library changes)Before:
After:
Related Issues
Fixes #3342
Types of changes
Checklist
Further comments
This change is scoped exclusively to the console reference applications - no library code was modified. The telemetry infrastructure remains fully functional for internal diagnostics and optional logging when users specify
--consoleand--logflags.Original prompt
This section details on the original issue you should resolve
<issue_title>ConsoleReferenceServer and ConsoleRefereceClient changed their default behaviour and UI</issue_title>
<issue_description>### Type of issue
Current Behavior
ConsoleReferenceServer and ConsoleRefereceClient changed their default behaviour and UI experience in the the following:
Issue 1
Under Debug mode, both now require to provide the --console and --log input parameters otherwise they throw (ex ConsoleReferenceServer):
Under Release mode the input parameters are not required, but than no useful messages are being displayed on the console due to them being piped through the log mechanism as the Issue2 describes.
A user that simply wants to run the console applications should not resort to enabling log messages and should be able to rely on the application console to display relevant information (as described in Issue2 previous behavior)
Issue 2
The console output has changed. While the previous versions (ex ConsoleReferenceServer) used to "cleanly" and concisely display that the server has started and display their discovery endpoints as thus:
The current version intermingles the messages that should be displayed on the console only with other log messages and displays them with [INF] level:
This new way of displaying the endpoints and other messages destined to be information messages to the user is confusing and should be displayed on their own not intermingled with other log messages.
Expected Behavior
Under Debug mode, the user of the ConsoleReferenceServer and ConsoleReferenceClient should not be forced to specify additional input parameters to see useful information displayed on the console.
Information destined to be displayed on the console should not be intermingled with other log messages.
ConsoleReferenceServer should present console output destined for informing the user, similar to: