1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

Optimise prefixed logger

Tweak the prefixed logger to only do the setup work the first time.
This commit is contained in:
J. Ryan Stinnett
2021-02-23 16:30:07 +00:00
parent 8d14dc9ee3
commit 8d779e8aec

View File

@@ -68,7 +68,10 @@ interface PrefixedLogger extends Logger {
export function getPrefixedLogger(prefix): PrefixedLogger {
const prefixLogger: PrefixedLogger = log.getLogger(`${DEFAULT_NAMESPACE}-${prefix}`);
prefixLogger.prefix = prefix;
prefixLogger.setLevel(log.levels.DEBUG);
if (prefixLogger.prefix !== prefix) {
// Only do this setup work the first time through, as loggers are saved by name.
prefixLogger.prefix = prefix;
prefixLogger.setLevel(log.levels.DEBUG);
}
return prefixLogger;
}