Skip to content

Commit 3b7b6cb

Browse files
committed
Fix #144
1 parent 942c7be commit 3b7b6cb

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

example/index.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Logger } from "../src";
1+
import { Logger, ILogObject } from "../src";
22

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

139139
const child = parent.getChildLogger({ requestId: "foo" }); // parent.settings.name = undefined
140140
child.info("child-test");
141+
142+
console.log("*******************");
143+
144+
const loggerParent = new Logger({ name: "parent" });
145+
const loggerChild1 = loggerParent.getChildLogger({ name: "child1" });
146+
const loggerChild2 = loggerParent.getChildLogger({ name: "child2" });
147+
148+
const logX = (logObject: ILogObject) => {
149+
console.log("child1 transport", logObject.argumentsArray);
150+
};
151+
loggerChild1.attachTransport(
152+
{
153+
silly: logX,
154+
debug: logX,
155+
trace: logX,
156+
info: logX,
157+
warn: logX,
158+
error: logX,
159+
fatal: logX,
160+
},
161+
"debug"
162+
);
163+
164+
loggerParent.info("parent");
165+
loggerChild1.info("child1");
166+
loggerChild2.info("child2");
167+
168+
const loggerChild12 = loggerChild1.getChildLogger({ name: "child1-2" });
169+
loggerChild12.info("child1-2");

src/LoggerWithoutCallSite.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ export class LoggerWithoutCallSite {
213213
public getChildLogger(settings?: ISettingsParam): Logger {
214214
const childSettings: ISettings = {
215215
...this.settings,
216+
attachedTransports: [...this.settings.attachedTransports],
216217
};
217218

218219
const childLogger: Logger = new (this.constructor as new (

0 commit comments

Comments
 (0)