@super-protocol/sdk-js 0.12.1-beta.2 → 0.12.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -84,6 +84,7 @@ var Jsonrpc = require('web3-core-requestmanager/src/jsonrpc');
|
|
|
84
84
|
var store_1 = __importDefault(require("../store"));
|
|
85
85
|
var Superpro_1 = __importDefault(require("../staticModels/Superpro"));
|
|
86
86
|
var SuperproToken_1 = __importDefault(require("../staticModels/SuperproToken"));
|
|
87
|
+
var Monitoring_1 = require("../utils/Monitoring");
|
|
87
88
|
var BlockchainConnector = /** @class */ (function (_super) {
|
|
88
89
|
__extends(BlockchainConnector, _super);
|
|
89
90
|
function BlockchainConnector() {
|
|
@@ -131,6 +132,7 @@ var BlockchainConnector = /** @class */ (function (_super) {
|
|
|
131
132
|
return [4 /*yield*/, Superpro_1.default.getTokenAddress(this.contract)];
|
|
132
133
|
case 1:
|
|
133
134
|
_a.addressHttps = _b.sent();
|
|
135
|
+
Monitoring_1.Monitoring.getInstance().initializeLogging();
|
|
134
136
|
this.initialized = true;
|
|
135
137
|
this.logger.trace("Initialized");
|
|
136
138
|
return [2 /*return*/];
|
|
@@ -413,6 +415,7 @@ var BlockchainConnector = /** @class */ (function (_super) {
|
|
|
413
415
|
BlockchainConnector.prototype.shutdown = function () {
|
|
414
416
|
_super.prototype.shutdown.call(this);
|
|
415
417
|
store_1.default.web3Https = undefined;
|
|
418
|
+
Monitoring_1.Monitoring.getInstance().shutdownLogging();
|
|
416
419
|
};
|
|
417
420
|
__decorate([
|
|
418
421
|
(0, utils_1.incrementMethodCall)()
|
|
@@ -2,8 +2,10 @@ export declare class Monitoring {
|
|
|
2
2
|
private static instance;
|
|
3
3
|
private logger;
|
|
4
4
|
private contractMethodCalls;
|
|
5
|
+
private interval?;
|
|
5
6
|
private constructor();
|
|
6
7
|
static getInstance(): Monitoring;
|
|
7
|
-
|
|
8
|
+
initializeLogging(): void;
|
|
9
|
+
shutdownLogging(): void;
|
|
8
10
|
incrementCall(methodName: string): void;
|
|
9
11
|
}
|
|
@@ -13,17 +13,15 @@ var Monitoring = /** @class */ (function () {
|
|
|
13
13
|
Monitoring.getInstance = function () {
|
|
14
14
|
if (!Monitoring.instance) {
|
|
15
15
|
Monitoring.instance = new Monitoring();
|
|
16
|
-
Monitoring.instance.initializeLogging();
|
|
17
16
|
}
|
|
18
17
|
return Monitoring.instance;
|
|
19
18
|
};
|
|
20
19
|
Monitoring.prototype.initializeLogging = function () {
|
|
21
20
|
var _this = this;
|
|
22
|
-
var checkInterval = process.env.PRINT_CONTRACT_CALLS_INTERVAL;
|
|
23
|
-
|
|
24
|
-
return;
|
|
21
|
+
var checkInterval = process.env.PRINT_CONTRACT_CALLS_INTERVAL || 300000;
|
|
22
|
+
this.shutdownLogging();
|
|
25
23
|
var startTs = Date.now();
|
|
26
|
-
setInterval(function () {
|
|
24
|
+
this.interval = setInterval(function () {
|
|
27
25
|
_this.contractMethodCalls.forEach(function (value, key) {
|
|
28
26
|
return _this.logger.debug({
|
|
29
27
|
methodName: key,
|
|
@@ -38,6 +36,9 @@ var Monitoring = /** @class */ (function () {
|
|
|
38
36
|
}, "Contract methods calls");
|
|
39
37
|
}, +checkInterval);
|
|
40
38
|
};
|
|
39
|
+
Monitoring.prototype.shutdownLogging = function () {
|
|
40
|
+
clearInterval(this.interval);
|
|
41
|
+
};
|
|
41
42
|
Monitoring.prototype.incrementCall = function (methodName) {
|
|
42
43
|
var prevValue = this.contractMethodCalls.get(methodName) || 0;
|
|
43
44
|
this.contractMethodCalls.set(methodName, prevValue + 1);
|
package/build/utils.js
CHANGED
|
@@ -172,9 +172,6 @@ var objectToTuple = function (data, format) {
|
|
|
172
172
|
exports.objectToTuple = objectToTuple;
|
|
173
173
|
function incrementMethodCall() {
|
|
174
174
|
return function (_target, propertyName, propertyDescriptor) {
|
|
175
|
-
if (!(0, exports.isNodeJS)()) {
|
|
176
|
-
return propertyDescriptor;
|
|
177
|
-
}
|
|
178
175
|
var monitoring = Monitoring_1.Monitoring.getInstance();
|
|
179
176
|
var method = propertyDescriptor.value;
|
|
180
177
|
propertyDescriptor.value = function () {
|