Phone country fix (#9167)

This commit is contained in:
Guillim
2024-12-20 15:28:17 +01:00
committed by GitHub
parent d08075f610
commit 928c99a725
3 changed files with 69 additions and 56 deletions

View File

@ -5,42 +5,44 @@ interface CommandLoggerOptions {
constructorName: string;
}
export const isCommandLogger = (
logger: Logger | CommandLogger,
): logger is CommandLogger => {
return typeof logger['setVerbose'] === 'function';
};
export class CommandLogger {
private logger: Logger;
private verbose: boolean;
private verboseFlag: boolean;
constructor(options: CommandLoggerOptions) {
this.logger = new Logger(options.constructorName);
this.verbose = options.verbose ?? true;
this.verboseFlag = options.verbose ?? false;
}
log(message: string, context?: string) {
if (this.verbose) {
this.logger.log(message, context);
}
log(message: string, ...optionalParams: [...any, string?]) {
this.logger.log(message, ...optionalParams);
}
error(message: string, stack?: string, context?: string) {
if (this.verbose) {
this.logger.error(message, stack, context);
}
this.logger.error(message, stack, context);
}
warn(message: string, context?: string) {
if (this.verbose) {
this.logger.warn(message, context);
}
this.logger.warn(message, context);
}
debug(message: string, context?: string) {
if (this.verbose) {
this.logger.debug(message, context);
this.logger.debug(message, context);
}
verbose(message: string, ...optionalParams: [...any, string?]) {
if (this.verboseFlag) {
this.logger.log(message, ...optionalParams);
}
}
verboseLog(message: string, context?: string) {
if (this.verbose) {
this.logger.verbose(message, context);
}
setVerbose(flag: boolean) {
this.verboseFlag = flag;
}
}