Skip to content

Commit

Permalink
Updated log request message to have full url so it's clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-yao committed Nov 19, 2019
1 parent 86ef425 commit 4d875fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function (req, res, next) {
const reqUrl = url.parse(req.url)
const reqPath = decodeURI(reqUrl.pathname)
if (reqPath.includes('/api/v')) {
logger.info('Proxy %s %s to backend, res status code: %s.', method, reqPath, status, { label: 'Connect', requestQuery: reqUrl.query, requestId: req.headers['x-request-id'] })
logger.info('Proxy %s request to %s, res status code: %s.', method, process.env.CONTENT_API_SERVER + reqPath, status, { label: 'Connect', requestQuery: reqUrl.query, requestId: req.headers['x-request-id'] })
} else {
logger.info('Server got request: %s %s %s', status, method, reqPath, { label: 'Connect', requestQuery: reqUrl.query, requestId: req.requestId })
}
Expand Down
4 changes: 3 additions & 1 deletion packages/ripple-nuxt-tide/lib/templates/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export default function ({ $axios, app, res }) {
$axios.onRequest(config => {
// Log all axios' requests
if (process.server) {
logger.info('Making %s request to %s', config.method.toUpperCase(), config.url, {label: 'Axios', requestId: config.headers['X-Request-Id']})
const baseURL = config.baseURL.length > 1 ? config.baseURL.substring(0, config.baseURL.length - 1) : ''
const fullUrl = baseURL + config.url
logger.info('Making %s request to %s', config.method.toUpperCase(), fullUrl, {label: 'Axios', requestId: config.headers['X-Request-Id']})
logger.debug('Headers %O', config.headers, {label: 'Axios'})
}
})
Expand Down

0 comments on commit 4d875fd

Please sign in to comment.