Duplicate Log Message (ARCH3162)
Ce contenu n’est pas encore disponible dans votre langue.
Key typescript.logging.duplicate-log-message · Severity info · Category logging
Identical log message literals repeated within the same class or module make log lines ambiguous about their source. It becomes impossible to tell which code path emitted them.
Incorrect
Section titled “Incorrect”function transfer(from: string, to: string) { if (!accounts.has(from)) logger.warn("invalid account"); if (!accounts.has(to)) logger.warn("invalid account");}Correct
Section titled “Correct”function transfer(from: string, to: string) { if (!accounts.has(from)) logger.warn("invalid source account", { account: from }); if (!accounts.has(to)) logger.warn("invalid target account", { account: to });}Make each log call unique with a distinguishing message and context.