9swampy / Telnet

Published on Nuget at https://www.nuget.org/packages/Telnet
http://www.nugetmusthaves.com/Package/Telnet
MIT License
124 stars 50 forks source link

Remove Console.Write() from TerminatedReadAsync #64

Closed pascaltippelt closed 2 years ago

pascaltippelt commented 2 years ago

As explained in https://github.com/9swampy/Telnet/issues/63

9swampy commented 2 years ago

For such a minor difference instead of using the Nuget package, why not just reference the project with your edit?

pascaltippelt commented 2 years ago

Because in my humble opinion returning a string like string s = await client.TerminatedReadAsync(...) and in the console is unnecessarily repeating.

9swampy commented 2 years ago

Agree it's noise but useful noise in my case. I wouldn't just remove it but making it optional, sure. Just commenting it out; reference the project instead of the Nuget package as I suggested in the meantime; i'm mulling an update as it's been a while...

XMoose25X commented 2 years ago

@9swampy - Is there any update on this issue / the project as a whole? I'm interested in making the logging optional as well but not sure how / if to contribute. Looks like you have a version 0.9.0 in pre-release and a 0.9.1 branch made. Please let me know the status of this project. Thanks!

pracsol commented 2 years ago

@9swampy, thanks for this toolset - really helpful. I would just add a vote that the console output be set up as optional with a method overload or client property, whatever. You seem open to the approach, is this pull request okay or are you looking for another approach to be submitted? For anyone else needing a workaround for the NuGet package, you can do something like this: var StandardOutput = Console.Out; // for reassignment after redirect Console.SetOut(TextWriter.Null); // redirect to null string ResponseMessage = await client.TerminatedReasAsync(ETX, TimeSpan.FromMilliseconds(5000)); // quiet response Console.SetOut(StandardOutput); // reassign stdout Console.WriteLine($"Received this much stuff: {ResponseMessage.Length}"); // or whatever you want..

9swampy commented 2 years ago

Didn't merge but the intent's included in the release 0.9.1 I've just pushed to Nuget.

Client.IsConsoleWrite = false; should do it.

Any problems, shout.