Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make slogger logging optional #377

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SLOGGER_LOG_TYPE=
SLOGGER_LOG_LEVEL=error #Log level, default is error
SLOGERR_API_ENDPOINT= #Slogger log api url
SLOGERR_API_TOKEN= #Slogger api token
ENABLE_SLOGERR=false #default set to false

# Logger configuration
LOG_LEVEL=info # Log level, default is info
Expand Down
4 changes: 3 additions & 1 deletion apps/api/src/config/logger.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const logDir = 'logs';
const combinedLogMaxSize = configService.get<string>('COMBINED_LOG_MAX_SIZE');
const errorLogMaxSize = configService.get<string>('ERROR_LOG_MAX_SIZE');

const enableSlogger = configService.get<string>('ENABLE_SLOGERR') || 'false';

const logFormat = format.combine(
format.timestamp(),
format.printf((info) => {
Expand Down Expand Up @@ -95,7 +97,7 @@ const transportsConfig = [
}),
new transports.DailyRotateFile(combinedLogOptions),
new transports.DailyRotateFile(errorLogOptions),
slogerrTransport,
...(enableSlogger === 'true' ? [slogerrTransport] : []),
];

export const loggerConfig = WinstonModule.createLogger({
Expand Down
Loading