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

Implement custom pocket logging formatters for commands and events. #2996

Merged
merged 1 commit into from
May 26, 2023

Conversation

shyamnamboodiripad
Copy link
Contributor

Also remove the #!log magic command, improve logging of routing slips and other random improvements around logging.

@@ -135,7 +132,8 @@ private void Run(ScheduledOperation operation)
{
_currentTopLevelOperation ??= operation.Value;

using var logOp = Log.OnEnterAndConfirmOnExit($"Run: {operation.Value}");
using var logOp = Log.OnEnterAndConfirmOnExit();
logOp.Info("{0}", operation.Value);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be great if we could say logOp.Infi(operation.Value) instead. This would need a change in PocketLogger to make the message template string optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding ability to pass argument(s) in OnEnterAndConfrimOnExit would also make the above case simpler. We could then just say Log.OnEnterAndConfirmOnExit(operation.Value).

@shyamnamboodiripad shyamnamboodiripad force-pushed the improve-logging branch 2 times, most recently from 63e6406 to 5515946 Compare May 25, 2023 20:11
@@ -60,4 +62,14 @@ private static IReadOnlyCollection<Diagnostic> RemapDiagnosticsFromLanguageNode(
)
).ToImmutableList();
}

internal static void StampRoutingSlipAndLog(this KernelEvent @event, Uri uri)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just add the log call into the Stamp* methods? Does it get too verbose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Stamp* methods don't have access to the event /command. So we need to add it to the caller of those methods.

Unless you think its ok to change the public Stamp* methods to pass in the event / command... But even then, we only want to log when routing slip is stamped inside the tool process - but not when it is stamped within the (de)serializer.

Copy link
Contributor

Choose a reason for hiding this comment

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

The deserialization process should not call Stamp. If it still does that we should fix it.

Copy link
Contributor Author

@shyamnamboodiripad shyamnamboodiripad May 25, 2023

Choose a reason for hiding this comment

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

It does currently. See https://github.com/dotnet/interactive/blob/main/src/Microsoft.DotNet.Interactive/Connection/KernelCommandEnvelope.cs#L186.

To fix this, I guess RoutingSlip should have a constructor that accepts all deserialized uris (and tags), and we need a KernelCommand.SetRoutingSlip (similar to KernelCommand.SetToken) to initialize KernelCommand.RoutingSlip post deserialization.

Is this what you were implying? If yes, I can look into that in a follow up PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that sounds right.

Also remove the #!log magic command, improve logging of routing slips and other random improvements around logging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants