Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d015a3b

Browse files
try winston logging
1 parent d83374a commit d015a3b

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

‎functions/aws-serverless-express.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import morgan from 'morgan'
55
import bodyParser from 'body-parser'
66
import compression from 'compression'
77
import customLogger from './utils/logger'
8+
import expressWinston from 'express-winston'
9+
import winston from 'winston'
810

911
const app = express()
1012
const router = express.Router()
1113

1214
router.use(compression())
1315

14-
app.use(morgan(customLogger))
16+
// app.use(morgan(customLogger))
1517

1618
router.get('/users', (req, res) => {
1719
res.json({
@@ -46,12 +48,30 @@ router.get('/hello/', function(req, res){
4648
res.send('hello world')
4749
})
4850

51+
app.use(expressWinston.logger({
52+
transports: [
53+
new winston.transports.Console({
54+
json: true,
55+
colorize: true
56+
})
57+
]
58+
}))
59+
4960
app.use('/.netlify/functions/aws-serverless-express/', router)
5061

5162
router.use(cors())
5263
router.use(bodyParser.json())
5364
router.use(bodyParser.urlencoded({ extended: true }))
5465

66+
app.use(expressWinston.errorLogger({
67+
transports: [
68+
new winston.transports.Console({
69+
json: true,
70+
colorize: true
71+
})
72+
]
73+
}));
74+
5575
const binaryMimeTypes = [
5676
'application/javascript',
5777
'application/json',

‎package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
"compression": "^1.7.2",
99
"cors": "^2.8.4",
1010
"express": "^4.16.3",
11+
"express-winston": "^2.5.1",
1112
"morgan": "^1.9.0",
1213
"react": "^16.4.0",
1314
"react-dom": "^16.4.0",
1415
"react-scripts": "1.1.4",
15-
"serverless-http": "^1.6.0"
16+
"serverless-http": "^1.6.0",
17+
"winston": "^3.0.0"
1618
},
1719
"scripts": {
1820
"start": "npm-run-all --parallel start:app start:server",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /