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

Start adding log module #73

Merged
merged 15 commits into from
Feb 12, 2021
Merged

Start adding log module #73

merged 15 commits into from
Feb 12, 2021

Conversation

jgraham
Copy link
Member

@jgraham jgraham commented Nov 17, 2020

This adds a domain with a single log.entryAdded event. It currently handles
both console logs and javascript execptions, but further additions are
going to be required for things like network errors.


Preview | Diff

@jgraham jgraham requested review from foolip and bwalderman November 17, 2020 20:22
@jgraham jgraham changed the title Start adding log domain Start adding log module Nov 17, 2020
@jgraham
Copy link
Member Author

jgraham commented Nov 17, 2020

More to do here but this is for early feedback on the general form.

@jgraham jgraham mentioned this pull request Nov 17, 2020
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

some cddl related comments

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@whimboo
Copy link
Contributor

whimboo commented Dec 2, 2020

In the last days I implemented the Runtime.consoleAPICalled from CDP for Firefox. And as noticed this kind of event is used for calls into the Console API (eg. console.log(), console.error(), ...), and for console messages. Any Javascript error is instead routed through Runtime.exceptionThrown.

As seen here we want all to be reported through the same kind event, and allow pre-filtering for types? How would we differentiate between a Javascript error and a call to console.error()? For now those would be identical, right? And I wonder if we have to differentiate between those.

index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated
field set to |realm| and the <code>args</code> field set to |serialized
args|.

1. Let |entry| be a map matching the <code>LogEntry</code> production, with the
Copy link
Member

Choose a reason for hiding this comment

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

This is a lot of glue code. As we keep going, is there a path to abstracting away most of this, so that events could just return maps and something else turns those into the right productions? Something a bit handwavy like https://dom.spec.whatwg.org/#concept-event-create which nonetheless everyone knows how to interpret.

Copy link
Member Author

Choose a reason for hiding this comment

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

So there's no difference between a map and a map that matches a production other that the latter is guaranteed to match a production. I was thinking we could have some pseudo-varargs function like:

When required to make a map matching CDDL production |production| with a variable number of arguments |args|:

  1. Let |result| be an [=map=] matching the production |production|, specifying the fields according to the values of |args| as follows:
  • If |arg| is not a [=tuple=], set the field with the name of |arg| to the value of arg.
  • If |arg| is a tuple, set the field named by the first item of |arg| to the second item of |arg|.
  1. Assert: |result| matches |production|

  2. Return |result|

And then you would use it like:

  1. [=Make a map matching the CDDL production=] LogEntry with ("type", "console"), |level|, |text|, |timestamp| and |extra|/

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
Base automatically changed from contexts to master December 11, 2020 17:06
@jgraham
Copy link
Member Author

jgraham commented Dec 11, 2020

OK, I fied a few issues, but need to come back and improve the way we hook into other specs.

index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@jgraham jgraham requested a review from foolip December 17, 2020 13:35
index.bs Outdated
LogLevel = "debug" / "info" / "warning" / "error"

LogEntry = {
type: text,
Copy link
Contributor

@sadym-chromium sadym-chromium Jan 25, 2021

Choose a reason for hiding this comment

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

Don't we need a context in the LogEntry? ConsoleLogEntry has a realm, but we don't have a mechanism to match the Realm and the BrowsingContext yet.

Suggested change
type: text,
?context: BrowsingContext,
type: text,

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this makes sense, although of course the proposed change isn't enough to actually populate the context id. I was looking at what CDP has and it doesn't seem to have this for Log.LogEntry. How do existing clients/implementations work here?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the Log.LogEntry event is global per connection, while Runtime.consoleAPICalled has an executionContextId.

Copy link
Member Author

Choose a reason for hiding this comment

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

I remembered the reason we don't provide a context id but just a realm id is that something like a service worker has a realm but not a context. We could of course provide both, but I expect that we'll end up with a generic way of converting between them, and lots of places will take either a realm id or context id and work with both.

index.bs Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
@css-meeting-bot
Copy link
Member

The Browser Testing and Tools Working Group just discussed Start adding Logging module.

The full IRC log of that discussion <AutomatedTester> Topic: Start adding Logging module
<AutomatedTester> github https://github.com//pull/73
<AutomatedTester> github: https://github.com//pull/73
<AutomatedTester> jgraham: the update from my side is I havent been able to do much
<AutomatedTester> sadym: the main question, should we focus on scalability or the end user usability
<jgraham> q+
<foolip> q+
<AutomatedTester> ... as we focus on scalable we can create a situation that becomes unusable from a UX point of view
<AutomatedTester> q?
<AutomatedTester> ack jgraham
<AutomatedTester> jgraham: My understandin here is on the question is [describes how log events might work]. In the spec we js errors or log messages. These can have different types of arguments that come up.
<AutomatedTester> ... There are a few ways we could structure the data and go for the Union of all the fields that could come through
<AutomatedTester> .. that feels like a bad idea and you're encoding which fields could be null
<AutomatedTester> ... one way we can solve this it to have a base type that has the basic fields and then have items that build off that
<AutomatedTester> ... and the suggestion that was made lets have a flat structure and then have an "inheritence" type model
<AutomatedTester> ... I don't have a strong oppinion
<simonstewart> q+
<foolip> q-
<AutomatedTester> q?
<AutomatedTester> ... and it feels like what we decide here will set the precedent for the rest of the spec
<AutomatedTester> q?
<AutomatedTester> ack simonstewart
<AutomatedTester> simonstewart: The inheritence model makes sense because it make gives you how that would go
<foolip> q+
<AutomatedTester> ...but lets rather think of them as mixins
<AutomatedTester> jgraham: that makes sense
<AutomatedTester> q?
<AutomatedTester> ack foolip
<AutomatedTester> foolip: At the protocol level we can have this in CDDL
<AutomatedTester> ... and it seems we all agree
<AutomatedTester> q?

jgraham and others added 8 commits February 11, 2021 13:58
This adds a domain with a single log.entryAdded event. It currently handles
both console logs and javascript execptions, but further additions are
going to be required for things like network errors.
Co-authored-by: Christian Bromann <[email protected]>
Co-authored-by: Philip Jägenstedt <[email protected]>
Co-authored-by: Maksim Sadym <[email protected]>
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@jgraham jgraham requested a review from bwalderman February 12, 2021 12:18
Copy link
Contributor

@sadym-chromium sadym-chromium left a comment

Choose a reason for hiding this comment

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

LGTM with few comments

index.bs Show resolved Hide resolved
Comment on lines +2288 to +2289
1. For each |arg| of |args|, append the result of [=serialize as a remote
value=] given |arg|, null, true, and an empty [=set=] to |serialized args|.
Copy link
Contributor

Choose a reason for hiding this comment

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

Meaning with implicit maxDepth = null. Should serialisationMaxDepth be kind of a global param?

Copy link
Member Author

Choose a reason for hiding this comment

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

So, I think we're going to need to improve the control of serialization for the whole spec at some point. I think I'd prefer to work on that when we specify script execution. So maybe file an issue for now?

Copy link
Contributor

@sadym-chromium sadym-chromium Feb 12, 2021

Choose a reason for hiding this comment

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

Agree it's not in the scope of this PR.

Filed Allow maxDepth serialisation setting #86

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
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.

7 participants