logs icon indicating copy to clipboard operation
logs copied to clipboard

open question about logging data objects

Open devoncarew opened this issue 7 years ago • 6 comments

The current plan is to support this by converting them to json, then logging them through the String message param in the dart:developer API.

I'm not sure this will support all use cases (but haven't thought this through in detail). There are some advantages to allowing an object to be logged, ala the inspect(Object data) call (https://api.dartlang.org/be/158637/dart-developer/inspect.html). The reference to it is sent over the service protocol, and the original object still exists in the VM side of the wire to interact with.

devoncarew avatar Sep 25 '18 20:09 devoncarew

/cc @jacob314 who may have ideas.

pq avatar Sep 25 '18 21:09 pq

We could use inspect, which generally isn't hooked up in IDEs to inspect anything, but that would be re-interpreting its semantic meaning...

devoncarew avatar Sep 25 '18 21:09 devoncarew

what we want is the equivalent of window.console.log on the web which lets you log a variable number of arguments some of which are objects and some of which are text. For example console.log("Widget ", myWidget, "rebuilt due to ", myEvent);

the dart:developer inspect method only supports 1 arg but is in the right direction aside from that.

jacob314 avatar Sep 25 '18 21:09 jacob314

What are the concrete limitations to requiring the log payload be json-encodable?

Regarding objects, isn't there an object ID or something we can pass as a param?

@jacob314 : aren't you doing that already for the widget inspector?

pq avatar Sep 25 '18 21:09 pq

To be json encodable, the object needs to be a primitive, a List, or a Map. I hit this issue right off the bat w/ my sample project - I was trying to log a instance of one of my model classes.

I don't think we have access to the object ID that the VM would use to send over the wire.

Perhaps we should just look at extending dart:developer log a bit.

devoncarew avatar Sep 25 '18 21:09 devoncarew

+1 on long term extending dart:developer log to reach parity with what console.log provides on the web. Using the inspectors ID to object scheme would be fine for now. You can even leverage it from your package. Generally, the VM Service ID scheme is very limited and needs to support better ID persistence to work well for the logging use case. Otherwise, old log entry objects will not be accessible at surprising times.

On Tue, Sep 25, 2018 at 2:53 PM Devon Carew [email protected] wrote:

To be json encodable, the object needs to be a primitive, a List, or a Map. I hit this issue right off the bat w/ my sample project - I was trying to log a instance of one of my model classes.

I don't think we have access to the object ID that the VM would use to send over the wire.

Perhaps we should just look at extending dart:developer log a bit.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pq/logs/issues/2#issuecomment-424514539, or mute the thread https://github.com/notifications/unsubscribe-auth/ABK4PNXrFdOZEB1W2Bny3KrnocmhBdgeks5ueqXjgaJpZM4W5bt0 .

jacob314 avatar Sep 25 '18 22:09 jacob314