Skip to content

Commit

Permalink
Log route correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaschaaf committed Mar 21, 2020
1 parent fbf9e3a commit a086a76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/events/http/HttpServer.js
Expand Up @@ -250,8 +250,6 @@ export default class HttpServer {
// path must start with '/'
let hapiPath = path.startsWith('/') ? path : `/${path}`

const _path = hapiPath

// prepend stage to path
const stage = this.#options.stage || this.#serverless.service.provider.stage

Expand All @@ -278,9 +276,8 @@ export default class HttpServer {

this.#terminalInfo.push({
method,
path: _path,
path: hapiPath,
server,
stage,
})

// If the endpoint has an authorization function, create an authStrategy for the route
Expand Down
8 changes: 4 additions & 4 deletions src/serverlessLog.js
Expand Up @@ -36,12 +36,12 @@ export function setLog(serverlessLogRef) {
// logs based on:
// https://github.com/serverless/serverless/blob/master/lib/classes/CLI.js

function logRoute(method, server, stage, path, maxLength) {
function logRoute(method, server, path, maxLength) {
const methodColor = colorMethodMapping.get(method) ?? peachpuff
const methodFormatted = method.padEnd(maxLength, ' ')

return `${methodColor(methodFormatted)} ${yellow.dim('|')} ${grey.dim(
`${server}/${stage}`,
`${server}`,
)}${lime(path)}`
}

Expand All @@ -61,8 +61,8 @@ export function logRoutes(routeInfo) {
console.log(
boxen(
routeInfo
.map(({ method, path, server, stage }) =>
logRoute(method, server, stage, path, maxLength),
.map(({ method, path, server }) =>
logRoute(method, server, path, maxLength),
)
.join('\n'),
boxenOptions,
Expand Down

0 comments on commit a086a76

Please sign in to comment.