nauful / LibUA

Open-source OPC UA client and server library
Apache License 2.0
262 stars 94 forks source link

Remove Console.WriteLine in HandleReadRequest or provide an option to disable/redirect it #117

Closed smitha-cgi closed 1 year ago

smitha-cgi commented 1 year ago

When certain clients such as UAExport connect to a server they issue an initial read for a number of items in a single request. This request goes to HandleReadRequest in Application.cs, which then prints out a bunch of lines like this due to a Console.WriteLine being present at the end of the function:

Read node ns=0;i=11702 MaxArrayLength Value => ### NULL Read node ns=0;i=11705 MaxNodesPerRead Value => ### NULL Read node ns=0;i=2255 NamespaceArray Value => System.String[] Read node ns=0;i=2735 MaxBrowseContinuationPoints Value => ### NULL

This Console.WriteLine is not present in the NET version of the code, only in NET Core. Can it please be removed in the NET Core version, or could an option be provided to suppress it or redirect it using the ILogger that the server has access to? To work around this I have had to override the HandleReadRequest function keeping all of the code identical other than removing the Console.WriteLine call. This works, but it would be nice to not have all that duplicated code in my app.

nauful commented 1 year ago

Good idea. Removed for now, will investigate a proper tracing solution if needed in the future.