Skip to content

Logging prints [object Object] instead of actual object #196

@RTnhN

Description

@RTnhN

The web logging does not seem really reactive, so I was trying to debug it. I came across logging where it says what the previous data is.

console.debug('Sending heartbeat for previous data', previousData)

This yields

Console: {"lineNumber":1,"message":"Sending heartbeat for previous data [object Object]","message_level":1,"sourceIdentifier":3,"sourceURL":""}

When I stringify the previousData, I get something a little more messy but more useful:

Console: {"lineNumber":1,"message":"Sending heartbeat for previous data {\"audible\":false,\"incognito\":false,\"tabCount\":1,\"title\":\"Extensions\",\"url\":\"chrome://extensions/\"}","message_level":1,"sourceIdentifier":3,"sourceURL":""}

Or something like this could be done:

console.debug("Sending heartbeat for previous data:", Object.entries(previousData).map(([k, v]) => `${k}=${v}`).join(", "));

which yields:

Console: {"lineNumber":1,"message":"Sending heartbeat for previous data: audible=false, incognito=false, tabCount=6, title=New Issue, url=https://github.com/ActivityWatch/aw-watcher-web/issues/new","message_level":1,"sourceIdentifier":3,"sourceURL":""}

Really, it would be nice anywhere where there is an object in a console.debug or console.warn there would be a key decomposition of it.

I can also prepare a PR for this if you want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions