Go Slog JSON Handler
jasperchess
PROOP

a year ago

I am in the process of migrating from Logrus to Slog in my go application. I am using the NewJSONHandler method to initialise the logger and I set the logger as the default in init()

When I immediately log (using [slog.Info](slog.Info)) after initialising the new default, I only receive the message.

Why I'm wondering if this is a Railway issue is:
a) Even the default logger prepends "INFO" to the message
b) Using this approach in the rest of my infrastructure (not running on Railway) works correctly

If this doesn't sound like an issue with your logs I'm happy to continue debugging, but I just wanted to rule it out 🙂

Thanks!

Solved

12 Replies

jasperchess
PROOP

a year ago

b7ffa58d-4fc3-417f-8ad8-ffc29078d847


jasperchess
PROOP

a year ago

Also while I'm here, I don't have pro plan. I briefly upgraded but my role on discord has never been removed


brody
EMPLOYEE

a year ago

can you show me a screenshot of what your log looks like expanded?


jasperchess
PROOP

a year ago

Sigh… I didn't realise you could expand the logs 😅

Thanks for the help again Brody 🙏


brody
EMPLOYEE

a year ago

how could we have made that more visually obvious?


jasperchess
PROOP

a year ago

I think part of why I didn't end up expanding the log is that previously with logrus I wasn't using JSON logging so when I did expand the logs in the past I would just see:

deployment: 31325692-cfbf-4a1d-af09-dbb1c6e0a28a
replica: 0195d686-91f3-46a2-a6c8-437c84f7201b
service: 5d663c81-9cc5-4209-87f6-d81b06b48e83

I assumed expanding the log just showed Railway metadata.

Maybe it's the FE experience in me but, in front of the log message adding a {...} or similar? Also allowing click on the whole log instead of just the little "+" would be great! 🙂

1328236016275816400


brody
EMPLOYEE

a year ago

what if we showed that plus icon on logs that have extra JSON attributes, instead of only showing on hover


jasperchess
PROOP

a year ago

I think that would also definitely help


jasperchess
PROOP

a year ago

Thanks Brody! Appreciate the help 🙂


brody
EMPLOYEE

a year ago

no problem, I'll bring that UI change up to our product team to see if they like the idea too


brody
EMPLOYEE

a year ago

but for now, I'll mark this as solved, feel free to open a new thread if you have anymore questions


brody
EMPLOYEE

a year ago

!s


Status changed to Solved brody about 1 year ago


Loading...