Skip to content

Commit

Permalink
Now we're logging some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
chasers committed Jun 30, 2021
1 parent d77ee8d commit c6322ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions pages/api/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
import logger from '../../logger/logger'

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

data = {
requst: {
const data = {
request: {
method: req.method,
path: req.path
url: req.url
},
response: {
status: res.status
status: res.statusCode
}
}

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

Expand All @@ -24,7 +25,7 @@ export default function handler(req, res) {
onlyPino.info(data, "Handled response. Logged with pino.")

// We can also simply parse our object into JSON and log it with console.
console.info(JSON.parse(data), "Handled response. Logged with `console`.")
console.info(JSON.stringify(data), "Handled response. Logged with `console`.")

res.json({ name: 'John Doe' })
}
2 changes: 1 addition & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Head from 'next/head'
import Image from 'next/image'
import styles from '../styles/Home.module.css'
import logger from '../../logger/logger'
import logger from '../logger/logger'

export default function Home() {
// Logging to pino-logflare.
Expand Down

0 comments on commit c6322ba

Please sign in to comment.