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