Skip to content
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

Custom Log output #52

Closed
ArcadeArchie opened this issue Jun 19, 2020 · 8 comments
Closed

Custom Log output #52

ArcadeArchie opened this issue Jun 19, 2020 · 8 comments

Comments

@ArcadeArchie
Copy link

Is there already a way to redirect the console output for custom logging?

@joelverhagen
Copy link
Owner

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.

@ArcadeArchie
Copy link
Author

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.

@joelverhagen
Copy link
Owner

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.

@z3nth10n
Copy link

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

@developer82
Copy link

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?

@joelverhagen
Copy link
Owner

Great point @developer82, this is a very reasonable API to align upon. Want to make a PR to add this capability?

@developer82
Copy link

@joelverhagen downloaded the code. Will try...

@joelverhagen
Copy link
Owner

I've added support for this. I went with a simple C# event for stdout and another for stderr on TorSharpProxy. Try out version 2.11.0. I added this sample to help:
https://github.com/joelverhagen/TorSharp/blob/release/samples/CustomLogging/Program.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants