You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/common/test/unit-tests/logger.ts
+82-1
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
1
import{Yok}from"../../yok";
2
2
import{Logger}from"../../logger/logger";
3
3
import*aspathfrom"path";
4
+
import*asutilfrom"util";
4
5
import{assert}from"chai";
5
6
import*asfileSystemFilefrom"../../file-system";
7
+
import{LoggerConfigData}from"../../../constants";
6
8
7
9
constpasswordReplacement="*******";
8
10
constdebugTrace=["debug","trace"];
@@ -33,7 +35,11 @@ describe("logger", () => {
33
35
fs=testInjector.resolve("fs");
34
36
outputs={
35
37
debug: "",
36
-
trace: ""
38
+
trace: "",
39
+
info: "",
40
+
error: "",
41
+
context: {},
42
+
removedContext: {}
37
43
};
38
44
39
45
constlog4jsLogger={
@@ -42,6 +48,18 @@ describe("logger", () => {
42
48
},
43
49
trace: (...args: string[])=>{
44
50
outputs.trace+=args.join("");
51
+
},
52
+
info: (...args: string[])=>{
53
+
outputs.info+=util.format.apply(null,args);
54
+
},
55
+
error: (...args: string[])=>{
56
+
outputs.error+=util.format.apply(null,args);
57
+
},
58
+
addContext(key: string,value: any): void{
59
+
outputs.context[key]=value;
60
+
},
61
+
removeContext(key: string): void{
62
+
outputs.removedContext[key]=true;
45
63
}
46
64
};
47
65
@@ -139,4 +157,67 @@ describe("logger", () => {
139
157
assert.deepEqual(outputs.trace,`${request}${requestBody}`,"logger.trace should not obfuscate body of request unless it is towards api/itmstransporter");
140
158
});
141
159
});
160
+
161
+
describe("info",()=>{
162
+
[undefined,null,false,"string value",42,{obj: 1},["string value 1","string value 2"]].forEach(value=>{
163
+
it(`handles formatted message with '${value}' value in one of the args`,()=>{
164
+
logger.info("test %s",value);
165
+
assert.equal(outputs.info,`test ${value}`);
166
+
assert.deepEqual(outputs.context,{},"Nothing should be added to logger context.");
167
+
assert.deepEqual(outputs.removedContext,{},"Removed context should be empty.");
168
+
});
169
+
170
+
it(`handles formatted message with '${value}' value in one of the args and additional values passed to context`,()=>{
0 commit comments