Skip to content

Commit

Permalink
Fix #144
Browse files Browse the repository at this point in the history
  • Loading branch information
terehov committed Aug 23, 2022
1 parent 942c7be commit 3b7b6cb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
31 changes: 30 additions & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Logger } from "../src";
import { Logger, ILogObject } from "../src";

class MyClass {
private readonly _logger: Logger = new Logger({
Expand Down Expand Up @@ -138,3 +138,32 @@ parent.info("parent-test");

const child = parent.getChildLogger({ requestId: "foo" }); // parent.settings.name = undefined
child.info("child-test");

console.log("*******************");

const loggerParent = new Logger({ name: "parent" });
const loggerChild1 = loggerParent.getChildLogger({ name: "child1" });
const loggerChild2 = loggerParent.getChildLogger({ name: "child2" });

const logX = (logObject: ILogObject) => {
console.log("child1 transport", logObject.argumentsArray);
};
loggerChild1.attachTransport(
{
silly: logX,
debug: logX,
trace: logX,
info: logX,
warn: logX,
error: logX,
fatal: logX,
},
"debug"
);

loggerParent.info("parent");
loggerChild1.info("child1");
loggerChild2.info("child2");

const loggerChild12 = loggerChild1.getChildLogger({ name: "child1-2" });
loggerChild12.info("child1-2");
1 change: 1 addition & 0 deletions src/LoggerWithoutCallSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export class LoggerWithoutCallSite {
public getChildLogger(settings?: ISettingsParam): Logger {
const childSettings: ISettings = {
...this.settings,
attachedTransports: [...this.settings.attachedTransports],
};

const childLogger: Logger = new (this.constructor as new (
Expand Down

0 comments on commit 3b7b6cb

Please sign in to comment.