w3cj / hono-open-api-starter

A starter template for building fully documented type-safe JSON APIs with Hono and Open API
https://www.youtube.com/watch?v=sNh9PoM9sUE
MIT License
328 stars 34 forks source link

pino logger deprecation issue #3

Closed xkeshav closed 1 month ago

xkeshav commented 1 month ago

First of All Thank you very much for the awesome video tutorial.

while was going and rsetructuring up my hono server and learnt many good things. that pino-logger thing; I was tring but it is giving deprectaion error

can you help what changes I requires the pino-logger.ts file in order to work it well in production also.

image

w3cj commented 1 month ago

Thanks for letting me know! This error just means that you need to import it as pinoLogger now instead of logger:

-import { logger } from "hono-pino"
+import { pinoLogger } from "hono-pino"

I will update the template soon to reflect.

On another note, pino does a lot of node.js specific things, so I've been looking into another library logtape that support other runtimes, not just node.js - eventually I might add a built in middleware to stoker that uses logtape and then we can remove the dependency on pino.

xkeshav commented 1 month ago

Thanks, it worked.

I was trying with logtap when you suggested.

middlewares/configure-tap-log.ts

import { configure, getConsoleSink, getLogger } from "@logtape/logtape";

await configure({
  sinks: { console: getConsoleSink() },
  loggers: [{ category: "my-app", level: "debug", sinks: ["console"] }]
});

export default function loggerTap() { 
  return getLogger(["my-app"])
}

and later

  app.use("*", loggerTap());

but it gived typing issue ( which is because AppBindings belongs to pinoLogger ) but what are for this logger.

below is the screenshot which also throw warning in terminal too.

image