-
Notifications
You must be signed in to change notification settings - Fork 381
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
Conversation
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
.
63e6406
to
5515946
Compare
@@ -60,4 +62,14 @@ private static IReadOnlyCollection<Diagnostic> RemapDiagnosticsFromLanguageNode( | |||
) | |||
).ToImmutableList(); | |||
} | |||
|
|||
internal static void StampRoutingSlipAndLog(this KernelEvent @event, Uri uri) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that sounds right.
5515946
to
ad4eb81
Compare
ad4eb81
to
da04a1a
Compare
Also remove the #!log magic command, improve logging of routing slips and other random improvements around logging.
da04a1a
to
5bbe1e3
Compare
Also remove the #!log magic command, improve logging of routing slips and other random improvements around logging.