Skip to content

Commit

Permalink
fix: set log level
Browse files Browse the repository at this point in the history
  • Loading branch information
Orkuncakilkaya committed May 10, 2024
1 parent 9de781d commit a02fbf9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions proxy/utils/log.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { CloudFrontRequest } from 'aws-lambda'
import { getHeaderValue } from './headers'

/**
* This function depends on 'fpjs_debug' boolean value, determining whether debug logs are going to be logged or not.
* @param request {CloudFrontRequest}
*/
export function setLogLevel(request?: CloudFrontRequest) {
const debugValue = request ? getHeaderValue(request, 'fpjs_debug') : undefined
const level = debugValue === 'true' ? 'DEBUG' : 'ERROR'
process.env.AWS_LAMBDA_LOG_LEVEL = level
if (!debugValue) {
console.debug = () => null
}
}

0 comments on commit a02fbf9

Please sign in to comment.