Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chasers committed Jun 30, 2021
1 parent 0f527a7 commit fe01a5f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const logger = pino({
},
level: "debug",
base: {
env: process.env.ENV || "ENV not set",
env: process.env.NODE_ENV,
revision: process.env.VERCEL_GITHUB_COMMIT_SHA,
},
}, stream);
Expand Down
1 change: 1 addition & 0 deletions pages/api/error-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import logger from '../../logger/logger'
export default function handler(req, res) {

// Lets log an error with console here.

try {
throw new Error('Whoops!')
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions pages/api/error-pino-logflare.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import logger from '../../logger/logger'
export default function handler(req, res) {

// Lets log an error with pino-logflare here.

try {
throw new Error('Whoops! Error with pino-logflare.')
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions pages/api/error-pino.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import logger from '../../logger/logger'
export default function handler(req, res) {

// Lets log an error with pino here.

try {
throw new Error('Whoops! Error with pino.')
} catch (e) {
Expand Down
3 changes: 1 addition & 2 deletions pages/api/hello-console.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction

import logger from '../../logger/logger'

export default function handler(req, res) {
res.status(200)

Expand All @@ -16,6 +14,7 @@ export default function handler(req, res) {
}

// We can also simply parse our object into JSON and log it with console.

console.info(JSON.stringify(data), "Handled response. Logged with `console`.")

res.json({ name: 'John Doe' })
Expand Down
3 changes: 1 addition & 2 deletions pages/api/hello-pino-logflare.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction

import logger from '../../logger/logger'

export default function handler(req, res) {
res.status(200)

Expand All @@ -16,6 +14,7 @@ export default function handler(req, res) {
}

// Logging to pino-logflare

logger.info(data, "Handled response. Logged with pino-logflare.")

res.json({ name: 'John Doe' })
Expand Down
3 changes: 1 addition & 2 deletions pages/api/hello-pino.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction

import logger from '../../logger/logger'

export default function handler(req, res) {
res.status(200)

Expand All @@ -17,6 +15,7 @@ export default function handler(req, res) {

// Logging with straight pino.
// Both will end up in Vercel's log drains with slight different payloads.

const onlyPino = require('pino')()

onlyPino.info(data, "Handled response. Logged with pino.")
Expand Down

0 comments on commit fe01a5f

Please sign in to comment.