Skip to content

Refactor logging to allow a loggerfactory per session #1673

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

Merged
merged 3 commits into from
Jul 26, 2025

Conversation

desdesdes
Copy link
Contributor

Refactor logging to allow a loggerfactory per session specified in the ConnectionInfo.

This commit introduces an ILoggerFactory to various classes, replacing the static logger factory with an instance-based approach for more flexible and session-specific logging. These changes improve the logging framework's flexibility and maintainability and allow unit testing of logging.

…e ConnectionInfo.

This commit introduces an `ILoggerFactory` to various classes, replacing the static logger factory with an instance-based approach for more flexible and session-specific logging. These changes improve the logging framework's flexibility and maintainability and allow unit testing of logging.
@Rob-Hague
Copy link
Collaborator

ah and unfortunately a lot of the mocking tests are "strict" in that they expect every interface call to be declared. I think you can do whatever is easiest to get them working i.e. remove the strictness if it helps

@desdesdes
Copy link
Contributor Author

ah and unfortunately a lot of the mocking tests are "strict" in that they expect every interface call to be declared. I think you can do whatever is easiest to get them working i.e. remove the strictness if it helps

Removing the strictness and working around the null return would require a lot of ?? code in the library. So for now i chose the setup the logger everywhere. This create a lot of additions to the unit test, but I think this is the cleanest solution for now.

@desdesdes desdesdes requested review from Rob-Hague and mus65 July 23, 2025 14:27
Copy link
Collaborator

@Rob-Hague Rob-Hague left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise, although I have not tried it out to see if it addresses #1669 (I trust you have done that)

@mus65 any other comments?

@mus65
Copy link
Contributor

mus65 commented Jul 24, 2025

LGTM otherwise, although I have not tried it out to see if it addresses #1669 (I trust you have done that)

@mus65 any other comments?

I will take a closer look on the weekend.

@mus65
Copy link
Contributor

mus65 commented Jul 26, 2025

LGTM. I wrote a test case for this in a separate branch, but I'm not sure it's worth adding since it requires yet another dependency (test-only though). I would leave this up to @Rob-Hague .

This imho makes SshNetLoggingConfiguration kind of obselete, but marking it obsolete after just introducing it doesn't seem sensible. 😄

@Rob-Hague Rob-Hague merged commit d40bc43 into sshnet:develop Jul 26, 2025
3 checks passed
@Rob-Hague
Copy link
Collaborator

LGTM. I wrote a test case for this in a separate branch, but I'm not sure it's worth adding since it requires yet another dependency (test-only though). I would leave this up to @Rob-Hague .

That's a nice test to validate this change. I imagine it is less useful going forward (although perhaps moreso than some other tests...)

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

Successfully merging this pull request may close these issues.

3 participants