Skip to content

Commit

Permalink
sample pino-pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
leandroandrade committed Mar 21, 2024
1 parent 0e6c664 commit b774727
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
87 changes: 87 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-security": "^2.1.1",
"pino-pretty": "^11.0.0",
"tap": "^16.3.10"
}
}
23 changes: 23 additions & 0 deletions pino-pretty/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const Fastify = require('fastify');

(async () => {
const opts = {
logger: {
level: 'debug',
},
};

if (process.stdout.isTTY) {
opts.logger.transport = { target: 'pino-pretty' };
}

const app = Fastify(opts);

app.get('/', async (req, res) => {
return { hello: 'world' };
});

await app.listen({ port: 3000 });
})();

// curl -H 'x-log-level: error' http://localhost:3000

0 comments on commit b774727

Please sign in to comment.