Skip to content

Commit c14ba9b

Browse files
fix: use dhilog instead of slogerr (#388)
1 parent 54d2de6 commit c14ba9b

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

apps/api/.env.example

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ MAX_RETRY_COUNT=3 # Max retry count, default is 3
1717
ARCHIVE_LIMIT=1000 # Max notifications to archive, default is 1000
1818
ARCHIVE_INTERVAL=3600 # Interval (in seconds) for archiving notifications, default 3600 (every 1 hour)
1919

20-
# Slogger configuration
21-
SLOGGER_LOG_TYPE=
22-
SLOGGER_LOG_LEVEL=error #Log level, default is error
23-
SLOGERR_API_ENDPOINT= #Slogger log api url
24-
SLOGERR_API_TOKEN= #Slogger api token
25-
ENABLE_SLOGERR=false #default set to false
20+
# Dhilog configuration
21+
DHILOG_LOG_TYPE= # Custom "Log types" value defined on Dhilog portal
22+
DHILOG_LOG_LEVEL=error # Log level, default is error
23+
DHILOG_API_ENDPOINT= # Dhilog log api url
24+
DHILOG_API_TOKEN= # Dhilog api token
25+
ENABLE_DHILOG=false # Default set to false
2626

2727
# Logger configuration
2828
LOG_LEVEL=info # Log level, default is info

apps/api/src/common/logger/slogerr.transport.ts renamed to apps/api/src/common/logger/dhilog.transport.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ interface LogInfo {
2020
severity: string;
2121
}
2222

23-
export class SlogerrTransport extends TransportStream {
23+
export class DhilogTransport extends TransportStream {
2424
private readonly httpService: HttpService;
2525
private readonly configService: ConfigService;
26-
private readonly logger = new Logger(SlogerrTransport.name);
26+
private readonly logger = new Logger(DhilogTransport.name);
2727

2828
constructor(options: CustomTransportOptions) {
2929
super(options);
@@ -32,14 +32,14 @@ export class SlogerrTransport extends TransportStream {
3232
}
3333

3434
async log(info: LogInfo, callback: () => void): Promise<void> {
35-
const allowedLevels = (this.configService.get<string>('SLOGGER_LOG_LEVEL') || 'error')
35+
const allowedLevels = (this.configService.get<string>('DHILOG_LOG_LEVEL') || 'error')
3636
.split(',')
3737
.map((level) => level.trim());
38-
const logType = this.configService.get<string>('SLOGGER_LOG_TYPE') || 'Exceptions';
38+
const logType = this.configService.get<string>('DHILOG_LOG_TYPE') || 'Exceptions';
3939

4040
if (allowedLevels.includes(info.level)) {
41-
const apiEndpoint = this.configService.get<string>('SLOGERR_API_ENDPOINT');
42-
const apiKey = this.configService.get<string>('SLOGERR_API_TOKEN');
41+
const apiEndpoint = this.configService.get<string>('DHILOG_API_ENDPOINT');
42+
const apiKey = this.configService.get<string>('DHILOG_API_TOKEN');
4343

4444
this.logger.log(`Log Info: ${stringify(info)}`);
4545

@@ -67,13 +67,13 @@ export class SlogerrTransport extends TransportStream {
6767

6868
if (response.status !== 200) {
6969
this.logger.warn(
70-
`Failed to send log to Slogerr. Status: ${response.status}, Message: ${response.statusText}`,
70+
`Failed to send log to Dhilog. Status: ${response.status}, Message: ${response.statusText}`,
7171
);
7272
} else {
73-
this.logger.log('Error log successfully sent to Slogerr', response);
73+
this.logger.log('Error log successfully sent to Dhilog', response);
7474
}
7575
} catch (error) {
76-
this.logger.warn('Failed to send log to Slogerr', error.message);
76+
this.logger.warn('Failed to send log to Dhilog', error.message);
7777
}
7878
}
7979

apps/api/src/config/logger.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'winston-daily-rotate-file';
77
import { ConfigService } from '@nestjs/config';
88
import { name as applicationName } from 'package.json';
99
import DailyRotateFile from 'winston-daily-rotate-file';
10-
import { SlogerrTransport } from 'src/common/logger/slogerr.transport';
10+
import { DhilogTransport } from 'src/common/logger/dhilog.transport';
1111
import { stringify } from 'flatted';
1212

1313
const configService = new ConfigService();
@@ -19,7 +19,7 @@ const logDir = 'logs';
1919
const combinedLogMaxSize = configService.get<string>('COMBINED_LOG_MAX_SIZE');
2020
const errorLogMaxSize = configService.get<string>('ERROR_LOG_MAX_SIZE');
2121

22-
const enableSlogger = configService.get<string>('ENABLE_SLOGERR') || 'false';
22+
const enableDhilog = configService.get<string>('ENABLE_DHILOG') || 'false';
2323

2424
const logFormat = format.combine(
2525
format.timestamp(),
@@ -83,7 +83,7 @@ if (errorLogMaxSize === '0') {
8383
errorLogOptions.maxSize = '20m';
8484
}
8585

86-
const slogerrTransport = new SlogerrTransport({
86+
const dhilogTransport = new DhilogTransport({
8787
httpService,
8888
configService,
8989
});
@@ -98,7 +98,7 @@ const transportsConfig = [
9898
}),
9999
new transports.DailyRotateFile(combinedLogOptions),
100100
new transports.DailyRotateFile(errorLogOptions),
101-
...(enableSlogger === 'true' ? [slogerrTransport] : []),
101+
...(enableDhilog === 'true' ? [dhilogTransport] : []),
102102
];
103103

104104
export const loggerConfig = WinstonModule.createLogger({

0 commit comments

Comments
 (0)