opencode-antigravity-autopilot 2.2.9 → 2.2.10
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.
- package/README.md +1 -1
- package/dist/auth/AccountRotator.d.ts.map +1 -1
- package/dist/auth/AccountRotator.js +1 -1
- package/dist/auth/AccountRotator.js.map +1 -1
- package/dist/auth/TokenStorageReader.d.ts.map +1 -1
- package/dist/auth/TokenStorageReader.js +1 -1
- package/dist/auth/TokenStorageReader.js.map +1 -1
- package/package.json +2 -2
- package/dist/AsyncLogger.d.ts +0 -5
- package/dist/AsyncLogger.d.ts.map +0 -1
- package/dist/AsyncLogger.js +0 -78
- package/dist/AsyncLogger.js.map +0 -1
- package/dist/logger.d.ts +0 -2
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -30
- package/dist/logger.js.map +0 -1
- package/dist/rotation/reproduce_crash.d.ts +0 -2
- package/dist/rotation/reproduce_crash.d.ts.map +0 -1
- package/dist/rotation/reproduce_crash.js +0 -10
- package/dist/rotation/reproduce_crash.js.map +0 -1
- package/dist/scripts/scripts/test-agent-quota.js +0 -154
- package/dist/scripts/src/auth/AccountRotator.js +0 -143
- package/dist/scripts/src/auth/TokenStorageReader.js +0 -88
- package/dist/scripts/src/manager.js +0 -360
- package/dist/scripts/src/oh-my-opencode.js +0 -145
- package/dist/scripts/src/quota/ApiQuotaPoller.js +0 -340
- package/dist/scripts/src/quota/LSPFinder.js +0 -86
- package/dist/scripts/src/quota/QuotaCacheUpdater.js +0 -212
- package/dist/scripts/src/quota/QuotaPoller.js +0 -86
- package/dist/scripts/src/rotation/ModelSelector.js +0 -63
- package/dist/scripts/src/rotation/QuotaTracker.js +0 -105
- package/dist/scripts/src/types.js +0 -2
- package/dist/scripts/src/utils/logger.js +0 -130
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.QuotaPoller = void 0;
|
|
43
|
-
var axios_1 = __importDefault(require("axios"));
|
|
44
|
-
var QuotaPoller = /** @class */ (function () {
|
|
45
|
-
function QuotaPoller() {
|
|
46
|
-
if (!(this instanceof QuotaPoller)) {
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
return new QuotaPoller();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
QuotaPoller.prototype.checkQuota = function (port, csrfToken) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
var url, response, quotaInfo, error_1;
|
|
54
|
-
var _a, _b;
|
|
55
|
-
return __generator(this, function (_c) {
|
|
56
|
-
switch (_c.label) {
|
|
57
|
-
case 0:
|
|
58
|
-
_c.trys.push([0, 2, , 3]);
|
|
59
|
-
url = "http://127.0.0.1:".concat(port, "/exa.language_server_pb.LanguageServerService/GetUserStatus");
|
|
60
|
-
return [4 /*yield*/, axios_1.default.post(url, { ideName: "antigravity", ideVersion: "unknown" }, {
|
|
61
|
-
headers: {
|
|
62
|
-
'Content-Type': 'application/json',
|
|
63
|
-
'X-Codeium-Csrf-Token': csrfToken
|
|
64
|
-
}
|
|
65
|
-
})];
|
|
66
|
-
case 1:
|
|
67
|
-
response = _c.sent();
|
|
68
|
-
quotaInfo = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.clientModelConfigs) === null || _b === void 0 ? void 0 : _b.quotaInfo;
|
|
69
|
-
if (!quotaInfo) {
|
|
70
|
-
return [2 /*return*/, null];
|
|
71
|
-
}
|
|
72
|
-
return [2 /*return*/, {
|
|
73
|
-
remainingFraction: quotaInfo.remainingFraction,
|
|
74
|
-
resetTime: quotaInfo.resetTime
|
|
75
|
-
}];
|
|
76
|
-
case 2:
|
|
77
|
-
error_1 = _c.sent();
|
|
78
|
-
return [2 /*return*/, null];
|
|
79
|
-
case 3: return [2 /*return*/];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
return QuotaPoller;
|
|
85
|
-
}());
|
|
86
|
-
exports.QuotaPoller = QuotaPoller;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.ModelSelector = void 0;
|
|
15
|
-
var logger_1 = require("../utils/logger");
|
|
16
|
-
var ModelSelector = /** @class */ (function () {
|
|
17
|
-
function ModelSelector(quotaTracker, strategy) {
|
|
18
|
-
var _a, _b, _c, _d;
|
|
19
|
-
if (!(this instanceof ModelSelector)) {
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
return new ModelSelector(quotaTracker, strategy);
|
|
22
|
-
}
|
|
23
|
-
this.logger = (0, logger_1.getLogger)();
|
|
24
|
-
this.quotaTracker = quotaTracker;
|
|
25
|
-
this.strategy = strategy || { preferredModels: [], fallbackModels: [], quotaThreshold: 0.02 };
|
|
26
|
-
this.logger.info('ModelSelector', 'Initialized', {
|
|
27
|
-
preferredModelsCount: (_b = (_a = this.strategy.preferredModels) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
28
|
-
fallbackModelsCount: (_d = (_c = this.strategy.fallbackModels) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
29
|
-
quotaThreshold: this.strategy.quotaThreshold,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
ModelSelector.prototype.selectModel = function () {
|
|
33
|
-
this.logger.debug('ModelSelector', 'Selecting model', {
|
|
34
|
-
preferredModels: this.strategy.preferredModels,
|
|
35
|
-
fallbackModels: this.strategy.fallbackModels,
|
|
36
|
-
});
|
|
37
|
-
var preferredModel = this.quotaTracker.getBestAvailableModel(this.strategy.preferredModels);
|
|
38
|
-
if (preferredModel) {
|
|
39
|
-
this.logger.info('ModelSelector', 'Selected preferred model', { model: preferredModel });
|
|
40
|
-
return preferredModel;
|
|
41
|
-
}
|
|
42
|
-
this.logger.warn('ModelSelector', 'No preferred model available, trying fallbacks');
|
|
43
|
-
var fallbackModel = this.quotaTracker.getBestAvailableModel(this.strategy.fallbackModels);
|
|
44
|
-
if (fallbackModel) {
|
|
45
|
-
this.logger.info('ModelSelector', 'Selected fallback model', { model: fallbackModel });
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.logger.error('ModelSelector', 'No suitable model found (all exhausted or below threshold)');
|
|
49
|
-
}
|
|
50
|
-
return fallbackModel;
|
|
51
|
-
};
|
|
52
|
-
ModelSelector.prototype.updateStrategy = function (strategy) {
|
|
53
|
-
this.strategy = __assign(__assign({}, this.strategy), strategy);
|
|
54
|
-
};
|
|
55
|
-
ModelSelector.prototype.getStrategy = function () {
|
|
56
|
-
return __assign({}, this.strategy);
|
|
57
|
-
};
|
|
58
|
-
ModelSelector.prototype.getQuotaStates = function () {
|
|
59
|
-
return this.quotaTracker.getAllQuotaStates();
|
|
60
|
-
};
|
|
61
|
-
return ModelSelector;
|
|
62
|
-
}());
|
|
63
|
-
exports.ModelSelector = ModelSelector;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QuotaTracker = void 0;
|
|
4
|
-
var logger_1 = require("../utils/logger");
|
|
5
|
-
var QuotaTracker = /** @class */ (function () {
|
|
6
|
-
function QuotaTracker(quotaThreshold) {
|
|
7
|
-
if (quotaThreshold === void 0) { quotaThreshold = 0.02; }
|
|
8
|
-
if (!(this instanceof QuotaTracker)) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
return new QuotaTracker(quotaThreshold);
|
|
11
|
-
}
|
|
12
|
-
this.logger = (0, logger_1.getLogger)();
|
|
13
|
-
this.quotaState = new Map();
|
|
14
|
-
this.quotaThreshold = quotaThreshold;
|
|
15
|
-
this.logger.info('QuotaTracker', 'Initialized', {
|
|
16
|
-
quotaThreshold: quotaThreshold,
|
|
17
|
-
thresholdPercentage: "".concat((quotaThreshold * 100).toFixed(1), "%"),
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
QuotaTracker.prototype.updateQuota = function (model, quota) {
|
|
21
|
-
var previousState = this.quotaState.get(model);
|
|
22
|
-
var newState = {
|
|
23
|
-
model: model,
|
|
24
|
-
quotaFraction: quota.remainingFraction,
|
|
25
|
-
lastChecked: Date.now(),
|
|
26
|
-
resetTime: quota.resetTime,
|
|
27
|
-
};
|
|
28
|
-
this.quotaState.set(model, newState);
|
|
29
|
-
this.logger.debug('QuotaTracker', 'Quota updated', {
|
|
30
|
-
model: model,
|
|
31
|
-
previousFraction: previousState === null || previousState === void 0 ? void 0 : previousState.quotaFraction,
|
|
32
|
-
newFraction: quota.remainingFraction,
|
|
33
|
-
quotaPercentage: "".concat((quota.remainingFraction * 100).toFixed(1), "%"),
|
|
34
|
-
threshold: "".concat((this.quotaThreshold * 100).toFixed(1), "%"),
|
|
35
|
-
isAboveThreshold: quota.remainingFraction >= this.quotaThreshold,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
QuotaTracker.prototype.getQuotaForModel = function (model) {
|
|
39
|
-
return this.quotaState.get(model) || null;
|
|
40
|
-
};
|
|
41
|
-
QuotaTracker.prototype.isModelAvailable = function (model) {
|
|
42
|
-
var state = this.quotaState.get(model);
|
|
43
|
-
if (!state)
|
|
44
|
-
return true;
|
|
45
|
-
if (state.quotaFraction < this.quotaThreshold) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
};
|
|
50
|
-
QuotaTracker.prototype.getBestAvailableModel = function (candidates) {
|
|
51
|
-
var _a;
|
|
52
|
-
this.logger.debug('QuotaTracker', 'Finding best available model', {
|
|
53
|
-
candidatesCount: candidates.length,
|
|
54
|
-
candidates: candidates,
|
|
55
|
-
});
|
|
56
|
-
var bestModel = null;
|
|
57
|
-
var bestQuota = -1;
|
|
58
|
-
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
|
|
59
|
-
var model = candidates_1[_i];
|
|
60
|
-
if (!this.isModelAvailable(model)) {
|
|
61
|
-
this.logger.debug('QuotaTracker', 'Model unavailable (below threshold)', { model: model });
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
var state = this.quotaState.get(model);
|
|
65
|
-
var quota = (_a = state === null || state === void 0 ? void 0 : state.quotaFraction) !== null && _a !== void 0 ? _a : 1.0;
|
|
66
|
-
if (quota > bestQuota) {
|
|
67
|
-
bestQuota = quota;
|
|
68
|
-
bestModel = model;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (bestModel) {
|
|
72
|
-
this.logger.info('QuotaTracker', 'Best model found', {
|
|
73
|
-
model: bestModel,
|
|
74
|
-
quotaFraction: bestQuota,
|
|
75
|
-
quotaPercentage: "".concat((bestQuota * 100).toFixed(1), "%"),
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.logger.warn('QuotaTracker', 'No available model found among candidates', {
|
|
80
|
-
candidatesCount: candidates.length,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
return bestModel;
|
|
84
|
-
};
|
|
85
|
-
QuotaTracker.prototype.getAllQuotaStates = function () {
|
|
86
|
-
return Array.from(this.quotaState.values());
|
|
87
|
-
};
|
|
88
|
-
QuotaTracker.prototype.clearStaleData = function (maxAgeMs) {
|
|
89
|
-
if (maxAgeMs === void 0) { maxAgeMs = 300000; }
|
|
90
|
-
var now = Date.now();
|
|
91
|
-
for (var _i = 0, _a = this.quotaState.entries(); _i < _a.length; _i++) {
|
|
92
|
-
var _b = _a[_i], model = _b[0], state = _b[1];
|
|
93
|
-
if (now - state.lastChecked > maxAgeMs) {
|
|
94
|
-
this.quotaState.delete(model);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
QuotaTracker.prototype.clearAll = function () {
|
|
99
|
-
var count = this.quotaState.size;
|
|
100
|
-
this.quotaState.clear();
|
|
101
|
-
this.logger.info('QuotaTracker', 'Cleared all quota states', { clearedCount: count });
|
|
102
|
-
};
|
|
103
|
-
return QuotaTracker;
|
|
104
|
-
}());
|
|
105
|
-
exports.QuotaTracker = QuotaTracker;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AutopilotLogger = void 0;
|
|
7
|
-
exports.getLogger = getLogger;
|
|
8
|
-
exports.setLogger = setLogger;
|
|
9
|
-
var fs_1 = __importDefault(require("fs"));
|
|
10
|
-
var path_1 = __importDefault(require("path"));
|
|
11
|
-
var AutopilotLogger = /** @class */ (function () {
|
|
12
|
-
function AutopilotLogger(options) {
|
|
13
|
-
var _a;
|
|
14
|
-
this.levelPriority = {
|
|
15
|
-
debug: 0,
|
|
16
|
-
info: 1,
|
|
17
|
-
warn: 2,
|
|
18
|
-
error: 3,
|
|
19
|
-
};
|
|
20
|
-
var logDir = (options === null || options === void 0 ? void 0 : options.logDir) || '/tmp';
|
|
21
|
-
var filename = (options === null || options === void 0 ? void 0 : options.filename) || "autopilot-".concat(this.getDateString(), ".log");
|
|
22
|
-
this.logFilePath = path_1.default.join(logDir, filename);
|
|
23
|
-
this.enabled = (_a = options === null || options === void 0 ? void 0 : options.enabled) !== null && _a !== void 0 ? _a : true;
|
|
24
|
-
this.minLevel = (options === null || options === void 0 ? void 0 : options.minLevel) || 'info';
|
|
25
|
-
if (this.enabled) {
|
|
26
|
-
this.ensureLogDirectory();
|
|
27
|
-
this.logRotation();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
AutopilotLogger.prototype.getDateString = function () {
|
|
31
|
-
var now = new Date();
|
|
32
|
-
return now.toISOString().split('T')[0];
|
|
33
|
-
};
|
|
34
|
-
AutopilotLogger.prototype.ensureLogDirectory = function () {
|
|
35
|
-
var dir = path_1.default.dirname(this.logFilePath);
|
|
36
|
-
if (!fs_1.default.existsSync(dir)) {
|
|
37
|
-
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
AutopilotLogger.prototype.logRotation = function () {
|
|
41
|
-
try {
|
|
42
|
-
var dir = path_1.default.dirname(this.logFilePath);
|
|
43
|
-
var files = fs_1.default.readdirSync(dir);
|
|
44
|
-
var autopilotLogs = files.filter(function (f) { return f.startsWith('autopilot-') && f.endsWith('.log'); });
|
|
45
|
-
var now = Date.now();
|
|
46
|
-
var sevenDaysAgo = now - (7 * 24 * 60 * 60 * 1000);
|
|
47
|
-
for (var _i = 0, autopilotLogs_1 = autopilotLogs; _i < autopilotLogs_1.length; _i++) {
|
|
48
|
-
var file = autopilotLogs_1[_i];
|
|
49
|
-
var filePath = path_1.default.join(dir, file);
|
|
50
|
-
var stats = fs_1.default.statSync(filePath);
|
|
51
|
-
if (stats.mtimeMs < sevenDaysAgo) {
|
|
52
|
-
fs_1.default.unlinkSync(filePath);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
AutopilotLogger.prototype.shouldLog = function (level) {
|
|
60
|
-
if (!this.enabled)
|
|
61
|
-
return false;
|
|
62
|
-
return this.levelPriority[level] >= this.levelPriority[this.minLevel];
|
|
63
|
-
};
|
|
64
|
-
AutopilotLogger.prototype.formatLogEntry = function (entry) {
|
|
65
|
-
var dataStr = entry.data ? " | ".concat(JSON.stringify(entry.data)) : '';
|
|
66
|
-
return "[".concat(entry.timestamp, "] [").concat(entry.level.toUpperCase(), "] [").concat(entry.component, "] ").concat(entry.message).concat(dataStr, "\n");
|
|
67
|
-
};
|
|
68
|
-
AutopilotLogger.prototype.writeLog = function (entry) {
|
|
69
|
-
if (!this.shouldLog(entry.level))
|
|
70
|
-
return;
|
|
71
|
-
try {
|
|
72
|
-
var formatted = this.formatLogEntry(entry);
|
|
73
|
-
fs_1.default.appendFileSync(this.logFilePath, formatted, 'utf-8');
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
// Silently fail - don't use console
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
AutopilotLogger.prototype.debug = function (component, message, data) {
|
|
80
|
-
this.writeLog({
|
|
81
|
-
timestamp: new Date().toISOString(),
|
|
82
|
-
level: 'debug',
|
|
83
|
-
component: component,
|
|
84
|
-
message: message,
|
|
85
|
-
data: data,
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
AutopilotLogger.prototype.info = function (component, message, data) {
|
|
89
|
-
this.writeLog({
|
|
90
|
-
timestamp: new Date().toISOString(),
|
|
91
|
-
level: 'info',
|
|
92
|
-
component: component,
|
|
93
|
-
message: message,
|
|
94
|
-
data: data,
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
AutopilotLogger.prototype.warn = function (component, message, data) {
|
|
98
|
-
this.writeLog({
|
|
99
|
-
timestamp: new Date().toISOString(),
|
|
100
|
-
level: 'warn',
|
|
101
|
-
component: component,
|
|
102
|
-
message: message,
|
|
103
|
-
data: data,
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
AutopilotLogger.prototype.error = function (component, message, data) {
|
|
107
|
-
this.writeLog({
|
|
108
|
-
timestamp: new Date().toISOString(),
|
|
109
|
-
level: 'error',
|
|
110
|
-
component: component,
|
|
111
|
-
message: message,
|
|
112
|
-
data: data,
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
AutopilotLogger.prototype.getLogFilePath = function () {
|
|
116
|
-
return this.logFilePath;
|
|
117
|
-
};
|
|
118
|
-
return AutopilotLogger;
|
|
119
|
-
}());
|
|
120
|
-
exports.AutopilotLogger = AutopilotLogger;
|
|
121
|
-
var globalLogger = null;
|
|
122
|
-
function getLogger(options) {
|
|
123
|
-
if (!globalLogger) {
|
|
124
|
-
globalLogger = new AutopilotLogger(options);
|
|
125
|
-
}
|
|
126
|
-
return globalLogger;
|
|
127
|
-
}
|
|
128
|
-
function setLogger(logger) {
|
|
129
|
-
globalLogger = logger;
|
|
130
|
-
}
|