@rarible/logger
Advanced tools
Comparing version 0.9.1 to 0.9.5
export declare type LoggableValue = null | undefined | boolean | number | string | object; | ||
export declare type AbstractLogger = { | ||
raw(data: Record<string, LoggableValue>): void; | ||
trace(...params: LoggableValue[]): void; | ||
@@ -4,0 +5,0 @@ debug(...params: LoggableValue[]): void; |
@@ -17,5 +17,7 @@ import type { AbstractLogger, LoggableValue } from "../domain"; | ||
warn(...params: LoggableValue[]): void; | ||
raw(data: Record<string, LoggableValue>): void; | ||
private log; | ||
private rawAsync; | ||
private withContext; | ||
private getMessage; | ||
} |
@@ -50,2 +50,5 @@ "use strict"; | ||
}; | ||
RemoteLogger.prototype.raw = function (data) { | ||
this.rawAsync(data).then(); | ||
}; | ||
RemoteLogger.prototype.log = function (level) { | ||
@@ -57,14 +60,26 @@ var params = []; | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { | ||
var data, e_1; | ||
return (0, tslib_1.__generator)(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.rawAsync({ | ||
level: level, | ||
message: this.getMessage(params), | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
RemoteLogger.prototype.rawAsync = function (data) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { | ||
var finalData, e_1; | ||
return (0, tslib_1.__generator)(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.withContext({ | ||
level: level, | ||
message: this.getMessage(params), | ||
})]; | ||
return [4 /*yield*/, this.withContext(data)]; | ||
case 1: | ||
data = _a.sent(); | ||
this.batchManager.add(data); | ||
finalData = _a.sent(); | ||
this.batchManager.add(finalData); | ||
return [3 /*break*/, 3]; | ||
@@ -71,0 +86,0 @@ case 2: |
@@ -42,2 +42,31 @@ "use strict"; | ||
}); }); | ||
it("should correctly log raw data", function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { | ||
var handler, logger, _a, calls, result; | ||
return (0, tslib_1.__generator)(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
handler = jest.fn(); | ||
logger = new _1.RemoteLogger(handler, { | ||
dropBatchInterval: 100, | ||
}); | ||
logger.raw({ | ||
level: "INFO", | ||
message: "test raw", | ||
}); | ||
return [4 /*yield*/, new Promise(function (resolve) { | ||
setTimeout(function () { | ||
resolve([handler.mock.calls.length, handler.mock.calls[0][0]]); | ||
}, 200); | ||
})]; | ||
case 1: | ||
_a = _b.sent(), calls = _a[0], result = _a[1]; | ||
expect(calls).toEqual(1); | ||
expect(result).toStrictEqual([{ | ||
level: "INFO", | ||
message: "test raw", | ||
}]); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it("should correctly resolve contexts", function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { | ||
@@ -44,0 +73,0 @@ var handler, logger, _a, calls, result; |
@@ -10,2 +10,3 @@ import type { AbstractLogger, LoggableValue } from "./domain"; | ||
warn(...args: LoggableValue[]): void; | ||
raw(data: Record<string, LoggableValue>): void; | ||
} |
@@ -43,4 +43,7 @@ "use strict"; | ||
}; | ||
UnionLogger.prototype.raw = function (data) { | ||
this.loggers.forEach(function (l) { return l.raw(data); }); | ||
}; | ||
return UnionLogger; | ||
}()); | ||
exports.UnionLogger = UnionLogger; |
{ | ||
"name": "@rarible/logger", | ||
"version": "0.9.1", | ||
"version": "0.9.5", | ||
"private": false, | ||
@@ -40,3 +40,3 @@ "description": "Logging utility for ts projects", | ||
}, | ||
"gitHead": "098b19c208422d47fd782f4cf45f8abeaefe89b9" | ||
"gitHead": "b539e4cee57b0b14e510a4e40d289faf436b264d" | ||
} |
Sorry, the diff of this file is not supported yet
39615
472