@rarible/logger
Advanced tools
Comparing version 0.9.15 to 0.10.0-alpha.0
@@ -1,3 +0,3 @@ | ||
export declare type LoggableValue = null | undefined | boolean | number | string | object; | ||
export declare type AbstractLogger = { | ||
export type LoggableValue = null | undefined | boolean | number | string | object; | ||
export type AbstractLogger = { | ||
raw(data: Record<string, any>): void; | ||
@@ -4,0 +4,0 @@ trace(...params: any[]): void; |
import type { RequestInit } from "node-fetch"; | ||
export declare class Warning extends Error { | ||
readonly name = "Warning"; | ||
constructor(message: string); | ||
} | ||
export type NetworkErrorConfig = { | ||
status: number | undefined; | ||
url: string; | ||
data: unknown | undefined; | ||
code: string | undefined; | ||
formData: unknown | undefined; | ||
method: string | undefined; | ||
}; | ||
export declare class NetworkError extends Error { | ||
status?: number; | ||
url: string; | ||
data?: any; | ||
code?: string; | ||
formData?: any; | ||
method?: string; | ||
constructor(options: { | ||
status?: number; | ||
url: string; | ||
data?: any; | ||
code?: string; | ||
formData?: any; | ||
method?: string; | ||
}); | ||
readonly name = "NetworkError"; | ||
readonly status: number | undefined; | ||
readonly url: string; | ||
readonly data?: any; | ||
readonly code: string; | ||
readonly formData?: any; | ||
readonly method: string | undefined; | ||
constructor(options: NetworkErrorConfig); | ||
} | ||
@@ -21,0 +24,0 @@ export declare function handleFetchErrorResponse(response: unknown, options?: { |
@@ -7,7 +7,7 @@ "use strict"; | ||
var Warning = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(Warning, _super); | ||
tslib_1.__extends(Warning, _super); | ||
function Warning(message) { | ||
var _this = _super.call(this, message) || this; | ||
_this.name = "Warning"; | ||
Object.setPrototypeOf(_this, Warning.prototype); | ||
_this.name = "Warning"; | ||
return _this; | ||
@@ -19,7 +19,7 @@ } | ||
var NetworkError = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(NetworkError, _super); | ||
tslib_1.__extends(NetworkError, _super); | ||
function NetworkError(options) { | ||
var _this = _super.call(this, JSON.stringify(options, null, " ")) || this; | ||
_this.name = "NetworkError"; | ||
Object.setPrototypeOf(_this, NetworkError.prototype); | ||
_this.name = "NetworkError"; | ||
_this.code = options.code || "NETWORK_ERR"; | ||
@@ -38,5 +38,5 @@ _this.status = options.status; | ||
var _a, _b, _c; | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var data; | ||
return (0, tslib_1.__generator)(this, function (_d) { | ||
return tslib_1.__generator(this, function (_d) { | ||
switch (_d.label) { | ||
@@ -43,0 +43,0 @@ case 0: |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./remote"), exports); | ||
(0, tslib_1.__exportStar)(require("./union"), exports); | ||
(0, tslib_1.__exportStar)(require("./errors"), exports); | ||
(0, tslib_1.__exportStar)(require("./utils/get-loggable-message"), exports); | ||
tslib_1.__exportStar(require("./remote"), exports); | ||
tslib_1.__exportStar(require("./union"), exports); | ||
tslib_1.__exportStar(require("./errors"), exports); | ||
tslib_1.__exportStar(require("./utils/get-loggable-message"), exports); |
import type { AbstractLogger } from "../domain"; | ||
export declare type RemoteLoggerConfig = { | ||
export type RemoteLoggerConfig = { | ||
initialContext: Promise<Record<string, string>>; | ||
@@ -4,0 +4,0 @@ context: Record<string, string>; |
@@ -10,3 +10,3 @@ "use strict"; | ||
function RemoteLogger(handler, config) { | ||
this.config = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, defaultConfig), config); | ||
this.config = tslib_1.__assign(tslib_1.__assign({}, defaultConfig), config); | ||
this.batchManager = new batcher_1.Batcher(this.config.dropBatchInterval, handler); | ||
@@ -19,3 +19,3 @@ } | ||
} | ||
this.log.apply(this, (0, tslib_1.__spreadArray)([domain_1.LogLevel.DEBUG], params, true)).then(); | ||
this.log.apply(this, tslib_1.__spreadArray([domain_1.LogLevel.DEBUG], params, true)).then(); | ||
}; | ||
@@ -27,3 +27,3 @@ RemoteLogger.prototype.error = function () { | ||
} | ||
this.log.apply(this, (0, tslib_1.__spreadArray)([domain_1.LogLevel.ERROR], params, true)).then(); | ||
this.log.apply(this, tslib_1.__spreadArray([domain_1.LogLevel.ERROR], params, true)).then(); | ||
}; | ||
@@ -35,3 +35,3 @@ RemoteLogger.prototype.info = function () { | ||
} | ||
this.log.apply(this, (0, tslib_1.__spreadArray)([domain_1.LogLevel.INFO], params, true)).then(); | ||
this.log.apply(this, tslib_1.__spreadArray([domain_1.LogLevel.INFO], params, true)).then(); | ||
}; | ||
@@ -43,3 +43,3 @@ RemoteLogger.prototype.trace = function () { | ||
} | ||
this.log.apply(this, (0, tslib_1.__spreadArray)([domain_1.LogLevel.TRACE], params, true)).then(); | ||
this.log.apply(this, tslib_1.__spreadArray([domain_1.LogLevel.TRACE], params, true)).then(); | ||
}; | ||
@@ -51,3 +51,3 @@ RemoteLogger.prototype.warn = function () { | ||
} | ||
this.log.apply(this, (0, tslib_1.__spreadArray)([domain_1.LogLevel.WARN], params, true)).then(); | ||
this.log.apply(this, tslib_1.__spreadArray([domain_1.LogLevel.WARN], params, true)).then(); | ||
}; | ||
@@ -62,8 +62,8 @@ RemoteLogger.prototype.raw = function (data) { | ||
} | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { | ||
return (0, tslib_1.__generator)(this, function (_a) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.rawAsync({ | ||
level: level, | ||
message: get_loggable_message_1.getLoggableMessage.apply(void 0, (0, tslib_1.__spreadArray)([this.config.maxByteSize], params, false)), | ||
message: get_loggable_message_1.getLoggableMessage.apply(void 0, tslib_1.__spreadArray([this.config.maxByteSize], params, false)), | ||
})]; | ||
@@ -78,5 +78,5 @@ case 1: | ||
RemoteLogger.prototype.rawAsync = function (data) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var finalData, e_1; | ||
return (0, tslib_1.__generator)(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -100,5 +100,5 @@ case 0: | ||
RemoteLogger.prototype.withContext = function (values) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var context; | ||
return (0, tslib_1.__generator)(this, function (_a) { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
@@ -108,3 +108,3 @@ case 0: return [4 /*yield*/, this.config.initialContext]; | ||
context = _a.sent(); | ||
return [2 /*return*/, (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, context), this.config.context), values)]; | ||
return [2 /*return*/, tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, context), this.config.context), values)]; | ||
} | ||
@@ -111,0 +111,0 @@ }); |
@@ -6,5 +6,5 @@ "use strict"; | ||
describe("RemoteLogger", function () { | ||
it("should correctly log data", function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { | ||
it("should correctly log data", function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var handler, logger, _a, calls, result; | ||
return (0, tslib_1.__generator)(this, function (_b) { | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
@@ -43,5 +43,5 @@ case 0: | ||
}); }); | ||
it("should correctly log raw data", function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { | ||
it("should correctly log raw data", function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var handler, logger, _a, calls, result; | ||
return (0, tslib_1.__generator)(this, function (_b) { | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
@@ -73,5 +73,5 @@ case 0: | ||
}); }); | ||
it("should correctly resolve contexts", function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { | ||
it("should correctly resolve contexts", function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var handler, logger, _a, calls, result; | ||
return (0, tslib_1.__generator)(this, function (_b) { | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
@@ -78,0 +78,0 @@ case 0: |
@@ -6,5 +6,5 @@ "use strict"; | ||
describe("utils/batcher", function () { | ||
it("should drop values as batch", function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () { | ||
it("should drop values as batch", function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
var myHandler, batcher, _a, amount, result; | ||
return (0, tslib_1.__generator)(this, function (_b) { | ||
return tslib_1.__generator(this, function (_b) { | ||
switch (_b.label) { | ||
@@ -11,0 +11,0 @@ case 0: |
@@ -13,4 +13,4 @@ "use strict"; | ||
var optional = fixed.map(function (p) { return (0, to_loggable_value_1.toLoggableValue)(p); }); | ||
return optional.length > 0 ? " " + optional.join(", ") : ""; | ||
return optional.length > 0 ? " ".concat(optional.join(", ")) : ""; | ||
} | ||
exports.getLoggableMessage = getLoggableMessage; |
@@ -5,9 +5,9 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
var json_stringify_safe_1 = (0, tslib_1.__importDefault)(require("json-stringify-safe")); | ||
var json_stringify_safe_1 = tslib_1.__importDefault(require("json-stringify-safe")); | ||
var is_error_1 = require("./is-error"); | ||
function toLoggableValue(x) { | ||
if ((0, is_error_1.isError)(x)) | ||
return "" + x; | ||
return "".concat(x); | ||
return (0, json_stringify_safe_1.default)(x); | ||
} | ||
exports.toLoggableValue = toLoggableValue; |
{ | ||
"name": "@rarible/logger", | ||
"version": "0.9.15", | ||
"version": "0.10.0-alpha.0", | ||
"private": false, | ||
@@ -26,14 +26,14 @@ "description": "Logging utility for ts projects", | ||
"devDependencies": { | ||
"@types/jest": "^27.0.2", | ||
"@types/json-stringify-safe": "5.0.0", | ||
"@types/node-fetch": "^2.6.1", | ||
"axios": "^0.26.1", | ||
"jest": "^27.3.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^27.0.7", | ||
"typescript": "^4.4.4" | ||
"@types/node-fetch": "^2.6.1" | ||
}, | ||
"peerDependencies": { | ||
"axios": "^0.26.1", | ||
"tslib": "^2.3.1" | ||
}, | ||
"peerDependenciesMeta": { | ||
"axios": { | ||
"optional": true | ||
} | ||
}, | ||
"publishConfig": { | ||
@@ -43,3 +43,3 @@ "access": "public", | ||
}, | ||
"gitHead": "f3dff7c9f493a0c5c0520afa7a867cbb3d8217e0" | ||
"gitHead": "cf8991ba75fcbd09c8a423cc1ddeab172348fd49" | ||
} |
Sorry, the diff of this file is not supported yet
55879
2
636
3