Skip to content

Commit

Permalink
Update: added support for storing logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mojcaostir committed Nov 1, 2022
1 parent ea08813 commit 7d5b183
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
build
.idea
.env
log
3 changes: 0 additions & 3 deletions setup/.env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Possible log levels: trace, debug, info, warn, error
LOG_LEVEL=info

# Possible log formats: pretty, json
LOG_FORMAT=json

# Databox
DATABOX_TOKEN=<token>

Expand Down
6 changes: 0 additions & 6 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ export enum LogLevel {
Trace = "trace",
}

export enum LogFormat {
Pretty = "pretty",
Json = "json",
}

export const config = {
logLevel: getAllowedConfig<LogLevel>("LOG_LEVEL", Object.values(LogLevel), LogLevel.Info),
logFormat: getAllowedConfig<LogFormat>("LOG_FORMAT", Object.values(LogFormat), LogFormat.Json),
gitHubToken: getConfig("GITHUB_PERSONAL_ACCESS_TOKEN"),
spotifyClientId: getConfig("SPOTIFY_CLIENT_ID"),
spotifyClientSecret: getConfig("SPOTIFY_CLIENT_SECRET"),
Expand Down
2 changes: 1 addition & 1 deletion src/util/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function createLogger(name: string): Logger {
messageKey: "msg",
errorKey: "err",
base: {},
transport: config.logFormat === "pretty" ? { target: "pino-pretty" } : undefined,
transport: { target: "pino/file", options: { destination: "log" } },
}).child({ logger: name });

return {
Expand Down

0 comments on commit 7d5b183

Please sign in to comment.