is there any way we could get some level of expans...
# sst
s
is there any way we could get some level of expansion instead of
[Object]
? like maybe 5-6 levels deep, maybe? (in the SST console)
t
wonder if I can detect if a log is json and turn it into the same tree structure
s
ooh yeah, that would be even better
f
Is this from a
console.log
inside the function?
@thdxr can SST do anything there if
console.log
is already serializing it to
[Object]
?
s
yeah I think it was from a console.log. now I don’t remember. is there some way we can log stuff to take advantage of the SST console’s fancy JSON expand/collapse feature?
t
Oh duh we can't
Unless we hook into console.log
d
console.log(JSON.stringify(obj, null, 2))
?
t
^ this is what I usually do
a
This is a problem when you deploy to Lambda and look at logs in CloudWatch too. It's one reason why I created @sailplane/logger.
s
yeah, logging is so weird & inconsistent. for nice formatting (and to work with CloudWatch queries), CloudWatch works best when you log
JSON.stringify(obj)
of course, that’s ugly & unreadable when working locally
I should just write some code to overwrite
console.log
with a version that checks
process.env.IS_LOCAL
, and if it’s local, log
util.inspect(obj, { depth: 10 })
, otherwise
JSON.stringify(obj)
a
That's part of what @sailplane/logger does! 😄 (It's also smart about outputting timestamps locally but not to Cloudwatch, and lets you set a context string that is added to each line.)
s
@Adam Fanello that’s cool, I’ll check it out!
j
@Adam Fanello thanks for sharing!