Skip to content

Commit

Permalink
feat: remove more serverless v2 logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jun 1, 2022
1 parent 404093c commit 6b101aa
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 44 deletions.
5 changes: 0 additions & 5 deletions src/debugLog.js

This file was deleted.

5 changes: 2 additions & 3 deletions src/events/http/HttpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import LambdaProxyIntegrationEventV2 from './lambda-events/LambdaProxyIntegrationEventV2.js'
import parseResources from './parseResources.js'
import payloadSchemaValidator from './payloadSchemaValidator.js'
import debugLog from '../../debugLog.js'
import serverlessLog, { logRoutes } from '../../serverlessLog.js'
import {
detectEncoding,
Expand Down Expand Up @@ -581,7 +580,7 @@ export default class HttpServer {

if (requestToken) {
if (requestToken !== this.#options.apiKey) {
debugLog(
this.log.debug(
`Method ${method} of function ${functionKey} token ${requestToken} not valid`,
)

Expand All @@ -595,7 +594,7 @@ export default class HttpServer {
const { usageIdentifierKey } = request.auth.credentials

if (usageIdentifierKey !== this.#options.apiKey) {
debugLog(
this.log.debug(
`Method ${method} of function ${functionKey} token ${usageIdentifierKey} not valid`,
)

Expand Down
9 changes: 1 addition & 8 deletions src/events/http/createAuthScheme.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Boom from '@hapi/boom'
import authCanExecuteResource from '../authCanExecuteResource.js'
import authValidateContext from '../authValidateContext.js'
import debugLog from '../../debugLog.js'
import serverlessLog from '../../serverlessLog.js'
import {
nullIfEmpty,
Expand Down Expand Up @@ -106,13 +105,7 @@ export default function createAuthScheme(
identityValidationExpression.test(authorization)
const finalAuthorization = matchedAuthorization ? authorization : ''

if (log) {
log.debug(
`Retrieved ${identityHeader} header "${finalAuthorization}"`,
)
} else {
debugLog(`Retrieved ${identityHeader} header "${finalAuthorization}"`)
}
log.debug(`Retrieved ${identityHeader} header "${finalAuthorization}"`)

event = {
...event,
Expand Down
13 changes: 2 additions & 11 deletions src/events/http/lambda-events/renderVelocityTemplateObject.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import velocityjs from 'velocityjs'
import runInPollutedScope from '../javaHelpers.js'
import debugLog from '../../../debugLog.js'
import { isPlainObject } from '../../../utils/index.js'

const { parse } = JSON
Expand Down Expand Up @@ -30,11 +29,7 @@ function renderVelocityString(velocityString, context, v3Utils) {
}).render(context, null, true),
)

if (log) {
log.debug('Velocity rendered:', renderResult || 'undefined')
} else {
debugLog('Velocity rendered:', renderResult || 'undefined')
}
log.debug('Velocity rendered:', renderResult || 'undefined')

// Haaaa Velocity... this language sure loves strings a lot
switch (renderResult) {
Expand Down Expand Up @@ -76,11 +71,7 @@ export default function renderVelocityTemplateObject(
// Let's check again
if (isPlainObject(toProcess)) {
entries(toProcess).forEach(([key, value]) => {
if (log) {
log.debug('Processing key:', key, '- value:', value)
} else {
debugLog('Processing key:', key, '- value:', value)
}
log.debug('Processing key:', key, '- value:', value)

if (typeof value === 'string') {
result[key] = renderVelocityString(value, context, v3Utils)
Expand Down
16 changes: 4 additions & 12 deletions src/utils/getHttpApiCorsConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import debugLog from '../debugLog.js'

export default function getHttpApiCorsConfig(httpApiCors, { log }) {
if (httpApiCors === true) {
// default values that should be set by serverless
Expand All @@ -17,18 +15,12 @@ export default function getHttpApiCorsConfig(httpApiCors, { log }) {
allowedOrigins: ['*'],
}

if (log) {
log.debug('Using CORS policy', c)
} else {
debugLog('Using CORS policy', c)
}
log.debug('Using CORS policy', c)

return c
}
if (log) {
log.debug('Using CORS policy', httpApiCors)
} else {
debugLog('Using CORS policy', httpApiCors)
}

log.debug('Using CORS policy', httpApiCors)

return httpApiCors
}
5 changes: 0 additions & 5 deletions src/utils/jsonPath.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { JSONPath } from 'jsonpath-plus'
// import debugLog from '../debugLog.js'

export default function jsonPath(json, path) {
// debugLog('Calling jsonPath:', path)

// NOTE: JSONPath returns undefined if 'json' is e.g. null, undefined, string,
// number (anything other than JSON)
const [result] =
Expand All @@ -12,7 +9,5 @@ export default function jsonPath(json, path) {
path,
}) || []

// debugLog('jsonPath resolved:', result)

return result
}

0 comments on commit 6b101aa

Please sign in to comment.