Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: Fix Netlify Functions logging #722

Merged
merged 1 commit into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"update-notifier": "^2.5.0",
"uuid": "^3.3.3",
"wait-port": "^0.2.2",
"winston": "^3.2.1",
"wrap-ansi": "^6.0.0",
"write-file-atomic": "^3.0.0"
},
Expand Down
11 changes: 10 additions & 1 deletion src/utils/serve-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const queryString = require('querystring')
const chokidar = require('chokidar')
const jwtDecode = require('jwt-decode')
const lambdaLocal = require('lambda-local')
const winston = require('winston')
const {
NETLIFYDEVLOG,
// NETLIFYDEVWARN,
Expand Down Expand Up @@ -104,6 +105,14 @@ function createHandler(dir) {
const watcher = chokidar.watch(dir, { ignored: /node_modules/ })
watcher.on('change', clearCache('modified')).on('unlink', clearCache('deleted'))

const logger = winston.createLogger({
levels: winston.config.npm.levels,
transports: [
new winston.transports.Console( { level: 'warn' }),
]
})
lambdaLocal.setLogger(logger)

return function(request, response) {
// handle proxies without path re-writes (http-servr)
const cleanPath = request.path.replace(/^\/.netlify\/functions/, '')
Expand Down Expand Up @@ -153,7 +162,7 @@ function createHandler(dir) {
callback: callback,
envfile: path.resolve(moduleDir, '.env'),
envdestroy: false,
verboseLevel: 0,
verboseLevel: 3,
})
}
}
Expand Down