DCsan
DCsan2y ago

better logging / debug output

is there a way to view better debug output? ie formatted json objects? It gets really hard having to manually decode the output I see like:
[CONVEX M(cards:buyCard)] [LOG] 'buyCard' { buyOpts: { user: { _creationTime: 1687745515377.9163, _id: '3nvhb1hwn7qyzha99dt5ctze9h70h0r', id: 'adi', revs: 100 }, userCard: { _creationTime: 1687745513515.5388, _id: '3j7ztxqnwk47azqawexvrb4r9h759f8', cardId: 'whale', lv: 3, user: 'omer' } } }
[CONVEX M(cards:buyCard)] [LOG] 'buyCard' { buyOpts: { user: { _creationTime: 1687745515377.9163, _id: '3nvhb1hwn7qyzha99dt5ctze9h70h0r', id: 'adi', revs: 100 }, userCard: { _creationTime: 1687745513515.5388, _id: '3j7ztxqnwk47azqawexvrb4r9h759f8', cardId: 'whale', lv: 3, user: 'omer' } } }
5 Replies
Indy
Indy2y ago
I'd try using JSON.stringify with a spacer parameter on your objects in your console.log statement: console.log(JSON.stringify({ x: 5, y: 6 }, null, 2)); See reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify If that doesn't work, let us know, it might be something we'd have to improve on our end. Also, check if the logs screen in the convex dashboard seems any better.
JSON.stringify() - JavaScript | MDN
The JSON.stringify() static method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified.
ballingt
ballingt2y ago
@DCsan Are you reading these logs in the browser console or on the Convex dashboard?
DCsan
DCsanOP2y ago
browser console a bit less ugly in the dashboard stringify in the console just gives me output with lots of \n in it in the dash also:
'try buyCard' '{\n "user": null,\n "owner": {\n "_creationTime": 1687750904475.0508,\n "_id": "3k8fn157w2ytf4pks5wtb3am9h71se0",\n "cardId": "whale",\n "lv": 3,\n "user": "omer"\n },\n "userCard": {\n "_creationTime": 1687750904475.0508,\n "_id": "3k8fn157w2ytf4pks5wtb3am9h71se0",\n "cardId": "whale",\n "lv": 3,\n "user": "omer"\n },\n "baseCard": {\n "_creationTime": 1687750902675.883,\n "_id": "3ew9tax9wy1rcys1nj2mkqrz9h7e4xr",\n "ap": 1,\n "creator": "seaman",\n "dp": 5,\n "id": "whale",'... 37 more characters
'try buyCard' '{\n "user": null,\n "owner": {\n "_creationTime": 1687750904475.0508,\n "_id": "3k8fn157w2ytf4pks5wtb3am9h71se0",\n "cardId": "whale",\n "lv": 3,\n "user": "omer"\n },\n "userCard": {\n "_creationTime": 1687750904475.0508,\n "_id": "3k8fn157w2ytf4pks5wtb3am9h71se0",\n "cardId": "whale",\n "lv": 3,\n "user": "omer"\n },\n "baseCard": {\n "_creationTime": 1687750902675.883,\n "_id": "3ew9tax9wy1rcys1nj2mkqrz9h7e4xr",\n "ap": 1,\n "creator": "seaman",\n "dp": 5,\n "id": "whale",'... 37 more characters
(any reason image posts are disabled here?)
Indy
Indy2y ago
oof sorry about that @ballingt any ideas? I'll put this on our list internally to improve either way.
ballingt
ballingt2y ago
We can start rendering those newlines properly! It's on a list, hearing from you helps prioritize@DCsan.

Did you find this page helpful?