add label
This commit is contained in:
parent
b78860fff7
commit
ce13920225
|
@ -17,7 +17,9 @@ export class AuthController {
|
|||
queue: 'logging-auth-create-crit',
|
||||
})
|
||||
public async authCreatedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.crit, 'critical'));
|
||||
this.logger.configure(
|
||||
loggerOptions('auth', level.crit, 'critical', 'create'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -27,7 +29,9 @@ export class AuthController {
|
|||
queue: 'logging-auth-delete-crit',
|
||||
})
|
||||
public async authDeletedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.crit, 'critical'));
|
||||
this.logger.configure(
|
||||
loggerOptions('auth', level.crit, 'critical', 'delete'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -37,7 +41,9 @@ export class AuthController {
|
|||
queue: 'logging-auth-username-add-warning',
|
||||
})
|
||||
public async authUsernameAddedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.warning, 'warning'));
|
||||
this.logger.configure(
|
||||
loggerOptions('auth', level.warning, 'warning', 'username-add'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -47,7 +53,9 @@ export class AuthController {
|
|||
queue: 'logging-auth-username-delete-warning',
|
||||
})
|
||||
public async authUsernameDeletedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.warning, 'warning'));
|
||||
this.logger.configure(
|
||||
loggerOptions('auth', level.warning, 'warning', 'username-delete'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -57,7 +65,9 @@ export class AuthController {
|
|||
queue: 'logging-auth-password-update-warning',
|
||||
})
|
||||
public async authPasswordUpdatedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.warning, 'warning'));
|
||||
this.logger.configure(
|
||||
loggerOptions('auth', level.warning, 'warning', 'password-update'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -67,7 +77,9 @@ export class AuthController {
|
|||
queue: 'logging-auth-username-update-warning',
|
||||
})
|
||||
public async authUsernameUpdatedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.warning, 'warning'));
|
||||
this.logger.configure(
|
||||
loggerOptions('auth', level.warning, 'warning', 'username-update'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,14 @@ export default function loggerOptions(
|
|||
dirname: string,
|
||||
level: level,
|
||||
filename: string,
|
||||
label: string,
|
||||
) {
|
||||
const transportOptions = new TransportOptions(dirname, level, filename);
|
||||
const transportOptions = new TransportOptions(
|
||||
dirname,
|
||||
level,
|
||||
filename,
|
||||
label,
|
||||
);
|
||||
const transport = new winston.transports.DailyRotateFile({
|
||||
...transportOptions,
|
||||
});
|
||||
|
|
|
@ -10,19 +10,21 @@ export class TransportOptions {
|
|||
filename = 'info';
|
||||
level = levelEnum.info;
|
||||
dirname = 'logs';
|
||||
label = '';
|
||||
format: winston.Logform.Format = winston.format.combine(
|
||||
filter(this.level),
|
||||
winston.format.timestamp(),
|
||||
winston.format.json(),
|
||||
);
|
||||
|
||||
constructor(dir: string, level: levelEnum, filename: string) {
|
||||
constructor(dir: string, level: levelEnum, filename: string, label: string) {
|
||||
this.level = level;
|
||||
this.filename = filename;
|
||||
this.dirname += '/' + dir;
|
||||
this.format = winston.format.combine(
|
||||
filter(this.level),
|
||||
winston.format.timestamp(),
|
||||
winston.format.label({ label }),
|
||||
winston.format.json(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export class UserController {
|
|||
queue: 'logging-user-create-info',
|
||||
})
|
||||
public async userCreatedInfoHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.info, 'info'));
|
||||
this.logger.configure(loggerOptions('user', level.info, 'info', 'create'));
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,9 @@ export class UserController {
|
|||
queue: 'logging-user-create-warning',
|
||||
})
|
||||
public async userCreatedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.warning, 'warning'));
|
||||
this.logger.configure(
|
||||
loggerOptions('user', level.warning, 'warning', 'create'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -37,7 +39,9 @@ export class UserController {
|
|||
queue: 'logging-user-create-crit',
|
||||
})
|
||||
public async userCreatedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.crit, 'critical'));
|
||||
this.logger.configure(
|
||||
loggerOptions('user', level.crit, 'critical', 'create'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -47,7 +51,7 @@ export class UserController {
|
|||
queue: 'logging-user-delete-info',
|
||||
})
|
||||
public async userDeletedInfoHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.info, 'info'));
|
||||
this.logger.configure(loggerOptions('user', level.info, 'info', 'delete'));
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -57,7 +61,9 @@ export class UserController {
|
|||
queue: 'logging-user-delete-crit',
|
||||
})
|
||||
public async userDeletedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.crit, 'critical'));
|
||||
this.logger.configure(
|
||||
loggerOptions('user', level.crit, 'critical', 'delete'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -67,7 +73,9 @@ export class UserController {
|
|||
queue: 'logging-user-read-warning',
|
||||
})
|
||||
public async userReadWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.warning, 'warning'));
|
||||
this.logger.configure(
|
||||
loggerOptions('user', level.warning, 'warning', 'read'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -77,7 +85,7 @@ export class UserController {
|
|||
queue: 'logging-user-update-info',
|
||||
})
|
||||
public async userUpdatedInfoHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.info, 'info'));
|
||||
this.logger.configure(loggerOptions('user', level.info, 'info', 'update'));
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
|
@ -87,7 +95,9 @@ export class UserController {
|
|||
queue: 'logging-user-update-crit',
|
||||
})
|
||||
public async userUpdatedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.crit, 'critical'));
|
||||
this.logger.configure(
|
||||
loggerOptions('user', level.crit, 'critical', 'update'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue