axiom + t3, how to log

I would like to use the req.log from next-axiom (see attached image) but I cant find req and res using t3. Any ideas on how to implement next-axiom into t3? https://github.com/axiomhq/next-axiom
GitHub
GitHub - axiomhq/next-axiom: The official Next.js library for Axiom.
The official Next.js library for Axiom. Contribute to axiomhq/next-axiom development by creating an account on GitHub.
16 Replies
Neto
Neto2y ago
GitHub
create-t3-app/base-context.ts at next · t3-oss/create-t3-app
The best way to start a full-stack, typesafe Next.js app - create-t3-app/base-context.ts at next · t3-oss/create-t3-app
Neto
Neto2y ago
on opts you have both req and resp
Max
Max2y ago
ok, so like this then ?
Max
Max2y ago
Max
Max2y ago
so that i can get the req in my actual code? i think i may be overcomplicating this
Neto
Neto2y ago
on the createInnerContext you should pass only stuff that you need in the procedures passing the whole request its not the best you can try only using import { log } from 'next-axiom'; to see if works if not
const { withAxiom } = require('next-axiom')

const { log } = withAxiom(req, res)

return createContextInner({
log,
...
})
const { withAxiom } = require('next-axiom')

const { log } = withAxiom(req, res)

return createContextInner({
log,
...
})
Max
Max2y ago
thank you that worked 👍
Neto
Neto2y ago
happy
Amos
Amos2y ago
GitHub
Usage with TRPC - how does this look? · Issue #64 · axiomhq/next-ax...
Hey, I'm building an application with the T3 stack and wanted to check if there is a better way to use Axiom with TRPC's router in a Next API route. Let me know if you see room for ...
theo (t3.gg)
theo (t3.gg)2y ago
fwiw I don't do this - I just rely on normal console logs coming through the vercel integration
Max
Max2y ago
yeah to be honest i realised i could just test it locally and i dont need axios at all :/
theo (t3.gg)
theo (t3.gg)2y ago
Axiom is useful for figuring out why things are breaking in production! I leave lots of logs in our backend code
Max
Max2y ago
True, i may just keep it to keep an eye on my function duration. I feel like that will be what breaks first for me where abouts is good practice to log would you say, i dont know if i should log all user events
theo (t3.gg)
theo (t3.gg)2y ago
There isn't really an established "best practices around logging". I try to imagine something is broken and think about what logs I would want if it was broken And add those in if I can Generally, before any important await or other promise, I try to log something
Max
Max2y ago
sounds logical, thanks all 🙂
Want results from more Discord servers?
Add your server