-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9de781d
commit a02fbf9
Showing
1 changed file
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |