feat(manager): set manager on created loggers, fix clear for placeholders
getLogger() now assigns manager on newly created loggers so isEnabledFor can check manager.disable. When replacing a Placeholder, _fixupParents is also called to establish the parent chain. clear() skips Placeholder entries that lack a clear method.
This commit is contained in:
parent
cfda9902f7
commit
94c7d4a1da
1 changed files with 6 additions and 1 deletions
|
|
@ -79,8 +79,10 @@ export class Manager {
|
|||
|
||||
if (existing instanceof Placeholder) {
|
||||
rv = new (this._loggerClass ?? loggerClass)(scope, NOTSET);
|
||||
rv.manager = this;
|
||||
this.loggers[scope] = rv;
|
||||
this._fixupChildren(existing, rv);
|
||||
this._fixupParents(rv);
|
||||
}
|
||||
else {
|
||||
rv = existing;
|
||||
|
|
@ -88,6 +90,7 @@ export class Manager {
|
|||
}
|
||||
else {
|
||||
rv = new (this._loggerClass ?? loggerClass)(scope, NOTSET);
|
||||
rv.manager = this;
|
||||
this.loggers[scope] = rv;
|
||||
this._fixupParents(rv);
|
||||
}
|
||||
|
|
@ -168,7 +171,9 @@ export class Manager {
|
|||
*/
|
||||
public clear() {
|
||||
Object.values(this.loggers).forEach((logger) => {
|
||||
logger.clear()
|
||||
if (!(logger instanceof Placeholder)) {
|
||||
logger.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue