Skip to content

Commit 904e554

Browse files
committed
add node-logging-2 example with the up pkg
1 parent a79f65d commit 904e554

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

oss/node-logging-2/Readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# Node Logging
3+
4+
Logging example with the `up` module.
5+
6+
## Deploy
7+
8+
```
9+
$ up
10+
```

oss/node-logging-2/app.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const https = require('https')
2+
const http = require('http')
3+
const { Logger } = require('up')
4+
const { PORT = 3000 } = process.env
5+
6+
const log = new Logger
7+
8+
http.createServer((req, res) => {
9+
const url = 'https://apex.sh'
10+
const start = Date.now()
11+
12+
log.info('timing request', { url })
13+
https.get(url, function () {
14+
const duration = Date.now() - start
15+
log.info('timing request complete', { url, duration })
16+
res.end(`Duration: ${duration}`)
17+
})
18+
19+
}).listen(PORT)

oss/node-logging-2/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"up": "^1.0.2"
4+
}
5+
}

oss/node-logging-2/up.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "app"
3+
}

oss/node-logging-2/yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
up@^1.0.2:
6+
version "1.0.2"
7+
resolved "https://registry.yarnpkg.com/up/-/up-1.0.2.tgz#25f87686fdac510f67444fe8b7bd1588b5595267"

0 commit comments

Comments
 (0)