TorSharp
TorSharp copied to clipboard
Custom Log output
Is there already a way to redirect the console output for custom logging?
Great idea! Currently there is no way to do it but it could be added without much difficulty. The VirtualDesktopToolRunner
might be a little harder since Windows API are directly p/invoked but it should be do-able. What sort of interface so you want?
Would something like this work?
public interface ITorSharpLogger
{
void OnOutput(string data);
void OnError(string data);
}
And you pass in an implementation of this ITorSharpLogger
via TorSharpSettings.Logger
?
None of this is implemented yet but I want to see what specifically you are thinking could work.
Doing it with an Inteface isnt such a bad idea but i think doing it over events would be better, like:
interface ITorSharpProxy
{
....
public event EventHandler<LogEventArgs> OnOutput;
public event EventHandler<ErrEventArgs> OnError;
....
}
ITorSharpProxy proxy = new TorSharpProxy();
proxy.OnOutput += OnOutput;
proxy.OnError += OnError;
or a mix between the two.
Sounds good! No clue when I will get to this. It sounds like a solid idea though and it seems quite doable as a community contribution.
This is a great project, but I'm also missing this feature, so I decided to implement in on my own!
I committed some changes as you can see on my fork. But I'm having troubles, so I decided to ask a question on StackOverflow, any help is appreciated! Thanks!
https://stackoverflow.com/questions/63345753/redirect-stdout-and-stderr-from-process-created-with-winapi
Just saw this since I was looking for a way to control the output channel as well... why not implement the use of the standard .NET core ILogger interface?
Great point @developer82, this is a very reasonable API to align upon. Want to make a PR to add this capability?
@joelverhagen downloaded the code. Will try...