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

using system diagnostics for logging #59

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

using system diagnostics for logging #59

wants to merge 5 commits into from

Conversation

NRHelmi
Copy link
Contributor

@NRHelmi NRHelmi commented Jan 22, 2023

No description provided.

@@ -52,6 +53,11 @@ public Client CreateClient()
{
httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
}

// system diagnostics logging configuration
testClient.TraceSource.Listeners.Add(new ConsoleTraceListener());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with this in principle, if we want to conform the logs with XUnit's logger (might be good for timing data and conforming format) we can create a new trace listener here, take the ITestOutputHelper in the ctor and use that to log out trace events

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


// system diagnostics logging configuration
testClient.TraceSource.Listeners.Add(new ConsoleTraceListener());
testClient.TraceSource.Switch.ShouldTrace(TraceEventType.Verbose);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note to think about: How should we parameterize the verbosity.. here we hardcode it to verbose which is fine to start, but is that always useful

@@ -50,13 +53,19 @@ public HttpClient HttpClient
set { _rest.HttpClient = value; }
}

public TraceSource TraceSource
Copy link
Collaborator

@torkins torkins Jan 23, 2023

Choose a reason for hiding this comment

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

to research - right now we think we can only do file-based configuration in .NET framework, but we need it in .NET core, how should we resolve this so programmatic configuration is not required?

Possibilities:
Our own config file interpretation
XUnit's config file
(understanding how this interplays with other environments the SDK is being run in such as ASP.NET core server)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

People complains about the missing ability to configure diagnostics traces using app.config or a similar configuration file, dotnet/runtime#23937
keep digging around, hopefully we won't need a custom config file interpretation 🙏

public Task<Database> CreateDatabaseAsync(string database, string engine)
{
return CreateDatabaseAsync(database, engine, false);
}

public async Task<Database> CreateDatabaseAsync(string database, string engine, bool overwrite)
{
_traceSource.TraceEvent(TraceEventType.Verbose, 0, $"creating database {database}");
Copy link
Collaborator

Choose a reason for hiding this comment

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

can just use some 100-offset number for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

2 participants