-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into snyk-upgrade-65739b77637fa00b9a0b7e7a6ffcc4c1
- Loading branch information
Showing
5 changed files
with
71 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,6 +1,32 @@ | ||
import * as winston from "winston" | ||
|
||
const LOG_LEVELS = winston.config.syslog.levels | ||
const DEFAULT_LOG_LEVEL = "debug" | ||
|
||
const getLogLevel = (): string => { | ||
const logLevelEnvVar = process.env.LOG_LEVEL | ||
if (logLevelEnvVar) { | ||
const isAllowedLogLevel = Object.keys(LOG_LEVELS) | ||
.find(level => logLevelEnvVar.toLowerCase() === level.toLowerCase()) | ||
if (!isAllowedLogLevel) { | ||
console.log("Unsupported log level: ", logLevelEnvVar) | ||
} else { | ||
return isAllowedLogLevel | ||
} | ||
} | ||
return DEFAULT_LOG_LEVEL | ||
|
||
|
||
} | ||
|
||
export const logger = winston.createLogger({ | ||
levels: winston.config.syslog.levels, | ||
transports: [ new winston.transports.Console() ], | ||
format: winston.format.combine( | ||
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), | ||
winston.format.json() | ||
), | ||
level: getLogLevel(), | ||
levels: LOG_LEVELS, | ||
transports: [new winston.transports.Console()], | ||
}) | ||
|
||
|
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
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