@mcesystems/logging-g4 1.0.71 → 1.0.73
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/dist/index.js +322 -155
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +322 -155
- package/dist/index.mjs.map +3 -3
- package/dist/types/logic/logClient.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -20278,55 +20278,172 @@ var require_src = __commonJS2({
|
|
|
20278
20278
|
}
|
|
20279
20279
|
});
|
|
20280
20280
|
var import_debug = __toESM2(require_src());
|
|
20281
|
-
|
|
20282
|
-
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
|
|
20286
|
-
|
|
20287
|
-
|
|
20288
|
-
|
|
20289
|
-
|
|
20290
|
-
|
|
20291
|
-
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
|
|
20298
|
-
|
|
20299
|
-
|
|
20300
|
-
|
|
20301
|
-
|
|
20302
|
-
}
|
|
20303
|
-
|
|
20304
|
-
|
|
20305
|
-
|
|
20306
|
-
|
|
20307
|
-
|
|
20308
|
-
|
|
20309
|
-
|
|
20310
|
-
|
|
20311
|
-
|
|
20312
|
-
|
|
20313
|
-
|
|
20314
|
-
|
|
20315
|
-
|
|
20316
|
-
|
|
20317
|
-
|
|
20318
|
-
|
|
20319
|
-
|
|
20320
|
-
|
|
20321
|
-
|
|
20322
|
-
|
|
20323
|
-
|
|
20324
|
-
|
|
20325
|
-
|
|
20326
|
-
|
|
20327
|
-
|
|
20328
|
-
|
|
20281
|
+
function createLoggers(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
20282
|
+
const logInfo22 = (0, import_debug.default)(`${namespace}:info`);
|
|
20283
|
+
const logTask = (0, import_debug.default)(`${namespace}:task`);
|
|
20284
|
+
const logError2 = (0, import_debug.default)(`${namespace}:error`);
|
|
20285
|
+
const logDetail2 = (0, import_debug.default)(`${namespace}:detail`);
|
|
20286
|
+
const logDebug = (0, import_debug.default)(`${namespace}:debug`);
|
|
20287
|
+
const logWarning = (0, import_debug.default)(`${namespace}:warning`);
|
|
20288
|
+
const logColor = (0, import_debug.default)(`${namespace}:color`);
|
|
20289
|
+
logInfo22.color = "19";
|
|
20290
|
+
logTask.color = "25";
|
|
20291
|
+
logError2.color = "1";
|
|
20292
|
+
logDetail2.color = "199";
|
|
20293
|
+
logWarning.color = "186";
|
|
20294
|
+
logDebug.color = "211";
|
|
20295
|
+
logColor.enabled = true;
|
|
20296
|
+
function setNamespace(namespace2) {
|
|
20297
|
+
logInfo22.namespace = `${namespace2}:info`;
|
|
20298
|
+
logTask.namespace = `${namespace2}:task`;
|
|
20299
|
+
logError2.namespace = `${namespace2}:error`;
|
|
20300
|
+
logDetail2.namespace = `${namespace2}:detail`;
|
|
20301
|
+
logWarning.namespace = `${namespace2}:warning`;
|
|
20302
|
+
logDebug.namespace = `${namespace2}:debug`;
|
|
20303
|
+
}
|
|
20304
|
+
function setLogLevel(level) {
|
|
20305
|
+
switch (level) {
|
|
20306
|
+
case "info":
|
|
20307
|
+
logInfo22.enabled = true;
|
|
20308
|
+
logTask.enabled = true;
|
|
20309
|
+
logError2.enabled = true;
|
|
20310
|
+
logWarning.enabled = true;
|
|
20311
|
+
logDetail2.enabled = false;
|
|
20312
|
+
logDebug.enabled = false;
|
|
20313
|
+
break;
|
|
20314
|
+
case "debug":
|
|
20315
|
+
logInfo22.enabled = true;
|
|
20316
|
+
logTask.enabled = true;
|
|
20317
|
+
logError2.enabled = true;
|
|
20318
|
+
logWarning.enabled = true;
|
|
20319
|
+
logDetail2.enabled = true;
|
|
20320
|
+
logDebug.enabled = true;
|
|
20321
|
+
break;
|
|
20322
|
+
case "none":
|
|
20323
|
+
logInfo22.enabled = false;
|
|
20324
|
+
logTask.enabled = false;
|
|
20325
|
+
logError2.enabled = false;
|
|
20326
|
+
logWarning.enabled = false;
|
|
20327
|
+
logDetail2.enabled = false;
|
|
20328
|
+
logDebug.enabled = false;
|
|
20329
|
+
break;
|
|
20330
|
+
}
|
|
20331
|
+
}
|
|
20332
|
+
setLogLevel(logLevel);
|
|
20333
|
+
function setColors(type, color) {
|
|
20334
|
+
switch (type) {
|
|
20335
|
+
case "info":
|
|
20336
|
+
logInfo22.color = color;
|
|
20337
|
+
break;
|
|
20338
|
+
case "task":
|
|
20339
|
+
logTask.color = color;
|
|
20340
|
+
break;
|
|
20341
|
+
case "error":
|
|
20342
|
+
logError2.color = color;
|
|
20343
|
+
break;
|
|
20344
|
+
case "detail":
|
|
20345
|
+
logDetail2.color = color;
|
|
20346
|
+
break;
|
|
20347
|
+
case "warning":
|
|
20348
|
+
logWarning.color = color;
|
|
20349
|
+
break;
|
|
20350
|
+
case "debug":
|
|
20351
|
+
logDebug.color = color;
|
|
20352
|
+
break;
|
|
20353
|
+
default:
|
|
20354
|
+
throw new Error(`Invalid log type: ${type}`);
|
|
20355
|
+
}
|
|
20356
|
+
}
|
|
20357
|
+
function printColors() {
|
|
20358
|
+
for (let i = 0; i < 256; i++) {
|
|
20359
|
+
logColor.color = `${i}`;
|
|
20360
|
+
logColor(`${i}: ${i}`);
|
|
20361
|
+
}
|
|
20362
|
+
}
|
|
20363
|
+
function logDataDetail(data, prefix = "# ") {
|
|
20364
|
+
if (data === null || data === void 0) {
|
|
20365
|
+
return `${prefix}<null or undefined>`;
|
|
20366
|
+
}
|
|
20367
|
+
if (typeof data !== "object") {
|
|
20368
|
+
return `${prefix}${String(data)}`;
|
|
20369
|
+
}
|
|
20370
|
+
const keys = Object.keys(data);
|
|
20371
|
+
let result = "";
|
|
20372
|
+
for (const key of keys) {
|
|
20373
|
+
result += `${prefix}${key}: `;
|
|
20374
|
+
if (key in data) {
|
|
20375
|
+
let dataKey = key;
|
|
20376
|
+
if (key in data) {
|
|
20377
|
+
dataKey = key;
|
|
20378
|
+
const value = data[dataKey];
|
|
20379
|
+
if (value === null || value === void 0) {
|
|
20380
|
+
result += `<${value === null ? "null" : "undefined"}>
|
|
20381
|
+
`;
|
|
20382
|
+
} else if (typeof value === "object") {
|
|
20383
|
+
result += `
|
|
20384
|
+
${logDataDetail(value, `${prefix} `)}
|
|
20385
|
+
`;
|
|
20386
|
+
} else {
|
|
20387
|
+
result += `${value}
|
|
20388
|
+
`;
|
|
20389
|
+
}
|
|
20390
|
+
}
|
|
20391
|
+
}
|
|
20392
|
+
}
|
|
20393
|
+
return result.trim();
|
|
20394
|
+
}
|
|
20395
|
+
function header(title, padding = 0) {
|
|
20396
|
+
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
20397
|
+
${" ".repeat(40 - title.length / 2)}${title}
|
|
20398
|
+
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
20399
|
+
}
|
|
20400
|
+
function logHeader(title) {
|
|
20401
|
+
logInfo22(`${header(title, 2)}`);
|
|
20402
|
+
}
|
|
20403
|
+
function logDataObject2(title, ...args) {
|
|
20404
|
+
const stack = new Error().stack?.split("\n")[2] || "";
|
|
20405
|
+
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
20406
|
+
let callerDetails = "";
|
|
20407
|
+
if (stackMatch) {
|
|
20408
|
+
const functionMatch = stack.match(/at (.+) \(/);
|
|
20409
|
+
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
20410
|
+
callerDetails = `${functionName}`;
|
|
20411
|
+
}
|
|
20412
|
+
logDetail2(`${header(`*${title}* ${callerDetails}`)}
|
|
20413
|
+
${args.reduce((acc, arg) => `${acc}
|
|
20414
|
+
${logDataDetail(arg)}`, "")}
|
|
20415
|
+
|
|
20416
|
+
${"=".repeat(80)}`);
|
|
20417
|
+
}
|
|
20418
|
+
function logErrorObject2(error, extraDetails) {
|
|
20419
|
+
if (error instanceof Error) {
|
|
20420
|
+
logError2(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
20421
|
+
Error Message:
|
|
20422
|
+
${error.message}
|
|
20423
|
+
Error Stack:
|
|
20424
|
+
${error.stack}
|
|
20425
|
+
${"=".repeat(80)}`);
|
|
20426
|
+
} else {
|
|
20427
|
+
logError2(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
20428
|
+
${"=".repeat(80)}`);
|
|
20429
|
+
}
|
|
20329
20430
|
}
|
|
20431
|
+
return {
|
|
20432
|
+
logInfo: logInfo22,
|
|
20433
|
+
logTask,
|
|
20434
|
+
logError: logError2,
|
|
20435
|
+
logDetail: logDetail2,
|
|
20436
|
+
logDebug,
|
|
20437
|
+
logWarning,
|
|
20438
|
+
logColor,
|
|
20439
|
+
setColors,
|
|
20440
|
+
printColors,
|
|
20441
|
+
logHeader,
|
|
20442
|
+
logDataObject: logDataObject2,
|
|
20443
|
+
logErrorObject: logErrorObject2,
|
|
20444
|
+
setLogLevel,
|
|
20445
|
+
setNamespace
|
|
20446
|
+
};
|
|
20330
20447
|
}
|
|
20331
20448
|
var AUTHORIZE_QUERY = `
|
|
20332
20449
|
query Authorize($input: AuthorizeInput!) {
|
|
@@ -20345,8 +20462,7 @@ var TOKEN_QUERY = `
|
|
|
20345
20462
|
}
|
|
20346
20463
|
}
|
|
20347
20464
|
`;
|
|
20348
|
-
|
|
20349
|
-
logNamespace("auth");
|
|
20465
|
+
var { logInfo } = createLoggers("auth");
|
|
20350
20466
|
var random = (0, import_node_util.promisify)(import_node_crypto.randomBytes);
|
|
20351
20467
|
async function getAuthToken(credentials, apiUrl) {
|
|
20352
20468
|
const authApiUrl = apiUrl || process.env.AUTH_API_URL;
|
|
@@ -21267,120 +21383,172 @@ var require_src4 = __commonJS3({
|
|
|
21267
21383
|
}
|
|
21268
21384
|
});
|
|
21269
21385
|
var import_debug2 = __toESM3(require_src4());
|
|
21270
|
-
|
|
21271
|
-
|
|
21272
|
-
|
|
21273
|
-
|
|
21274
|
-
|
|
21275
|
-
|
|
21276
|
-
|
|
21277
|
-
|
|
21278
|
-
|
|
21279
|
-
|
|
21280
|
-
|
|
21281
|
-
|
|
21282
|
-
|
|
21283
|
-
|
|
21284
|
-
|
|
21285
|
-
|
|
21286
|
-
|
|
21287
|
-
|
|
21288
|
-
|
|
21289
|
-
|
|
21290
|
-
|
|
21291
|
-
}
|
|
21292
|
-
|
|
21293
|
-
|
|
21294
|
-
|
|
21295
|
-
|
|
21296
|
-
|
|
21297
|
-
|
|
21298
|
-
|
|
21299
|
-
|
|
21300
|
-
|
|
21301
|
-
|
|
21302
|
-
|
|
21303
|
-
|
|
21304
|
-
|
|
21305
|
-
|
|
21306
|
-
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
|
|
21310
|
-
|
|
21311
|
-
|
|
21312
|
-
|
|
21313
|
-
|
|
21314
|
-
|
|
21315
|
-
|
|
21316
|
-
|
|
21317
|
-
|
|
21318
|
-
|
|
21319
|
-
}
|
|
21320
|
-
|
|
21321
|
-
|
|
21322
|
-
|
|
21323
|
-
|
|
21324
|
-
|
|
21325
|
-
|
|
21326
|
-
|
|
21327
|
-
|
|
21328
|
-
|
|
21329
|
-
|
|
21330
|
-
|
|
21331
|
-
|
|
21332
|
-
|
|
21386
|
+
function createLoggers2(namespace, logLevel = process.env.LOG_LEVEL ?? "none") {
|
|
21387
|
+
const logInfo3 = (0, import_debug2.default)(`${namespace}:info`);
|
|
21388
|
+
const logTask = (0, import_debug2.default)(`${namespace}:task`);
|
|
21389
|
+
const logError2 = (0, import_debug2.default)(`${namespace}:error`);
|
|
21390
|
+
const logDetail2 = (0, import_debug2.default)(`${namespace}:detail`);
|
|
21391
|
+
const logDebug = (0, import_debug2.default)(`${namespace}:debug`);
|
|
21392
|
+
const logWarning = (0, import_debug2.default)(`${namespace}:warning`);
|
|
21393
|
+
const logColor = (0, import_debug2.default)(`${namespace}:color`);
|
|
21394
|
+
logInfo3.color = "19";
|
|
21395
|
+
logTask.color = "25";
|
|
21396
|
+
logError2.color = "1";
|
|
21397
|
+
logDetail2.color = "199";
|
|
21398
|
+
logWarning.color = "186";
|
|
21399
|
+
logDebug.color = "211";
|
|
21400
|
+
logColor.enabled = true;
|
|
21401
|
+
function setNamespace(namespace2) {
|
|
21402
|
+
logInfo3.namespace = `${namespace2}:info`;
|
|
21403
|
+
logTask.namespace = `${namespace2}:task`;
|
|
21404
|
+
logError2.namespace = `${namespace2}:error`;
|
|
21405
|
+
logDetail2.namespace = `${namespace2}:detail`;
|
|
21406
|
+
logWarning.namespace = `${namespace2}:warning`;
|
|
21407
|
+
logDebug.namespace = `${namespace2}:debug`;
|
|
21408
|
+
}
|
|
21409
|
+
function setLogLevel(level) {
|
|
21410
|
+
switch (level) {
|
|
21411
|
+
case "info":
|
|
21412
|
+
logInfo3.enabled = true;
|
|
21413
|
+
logTask.enabled = true;
|
|
21414
|
+
logError2.enabled = true;
|
|
21415
|
+
logWarning.enabled = true;
|
|
21416
|
+
logDetail2.enabled = false;
|
|
21417
|
+
logDebug.enabled = false;
|
|
21418
|
+
break;
|
|
21419
|
+
case "debug":
|
|
21420
|
+
logInfo3.enabled = true;
|
|
21421
|
+
logTask.enabled = true;
|
|
21422
|
+
logError2.enabled = true;
|
|
21423
|
+
logWarning.enabled = true;
|
|
21424
|
+
logDetail2.enabled = true;
|
|
21425
|
+
logDebug.enabled = true;
|
|
21426
|
+
break;
|
|
21427
|
+
case "none":
|
|
21428
|
+
logInfo3.enabled = false;
|
|
21429
|
+
logTask.enabled = false;
|
|
21430
|
+
logError2.enabled = false;
|
|
21431
|
+
logWarning.enabled = false;
|
|
21432
|
+
logDetail2.enabled = false;
|
|
21433
|
+
logDebug.enabled = false;
|
|
21434
|
+
break;
|
|
21435
|
+
}
|
|
21436
|
+
}
|
|
21437
|
+
setLogLevel(logLevel);
|
|
21438
|
+
function setColors(type, color) {
|
|
21439
|
+
switch (type) {
|
|
21440
|
+
case "info":
|
|
21441
|
+
logInfo3.color = color;
|
|
21442
|
+
break;
|
|
21443
|
+
case "task":
|
|
21444
|
+
logTask.color = color;
|
|
21445
|
+
break;
|
|
21446
|
+
case "error":
|
|
21447
|
+
logError2.color = color;
|
|
21448
|
+
break;
|
|
21449
|
+
case "detail":
|
|
21450
|
+
logDetail2.color = color;
|
|
21451
|
+
break;
|
|
21452
|
+
case "warning":
|
|
21453
|
+
logWarning.color = color;
|
|
21454
|
+
break;
|
|
21455
|
+
case "debug":
|
|
21456
|
+
logDebug.color = color;
|
|
21457
|
+
break;
|
|
21458
|
+
default:
|
|
21459
|
+
throw new Error(`Invalid log type: ${type}`);
|
|
21460
|
+
}
|
|
21461
|
+
}
|
|
21462
|
+
function printColors() {
|
|
21463
|
+
for (let i = 0; i < 256; i++) {
|
|
21464
|
+
logColor.color = `${i}`;
|
|
21465
|
+
logColor(`${i}: ${i}`);
|
|
21466
|
+
}
|
|
21467
|
+
}
|
|
21468
|
+
function logDataDetail(data, prefix = "# ") {
|
|
21469
|
+
if (data === null || data === void 0) {
|
|
21470
|
+
return `${prefix}<null or undefined>`;
|
|
21471
|
+
}
|
|
21472
|
+
if (typeof data !== "object") {
|
|
21473
|
+
return `${prefix}${String(data)}`;
|
|
21474
|
+
}
|
|
21475
|
+
const keys = Object.keys(data);
|
|
21476
|
+
let result = "";
|
|
21477
|
+
for (const key of keys) {
|
|
21478
|
+
result += `${prefix}${key}: `;
|
|
21333
21479
|
if (key in data) {
|
|
21334
|
-
dataKey = key;
|
|
21335
|
-
|
|
21336
|
-
|
|
21337
|
-
|
|
21480
|
+
let dataKey = key;
|
|
21481
|
+
if (key in data) {
|
|
21482
|
+
dataKey = key;
|
|
21483
|
+
const value = data[dataKey];
|
|
21484
|
+
if (value === null || value === void 0) {
|
|
21485
|
+
result += `<${value === null ? "null" : "undefined"}>
|
|
21338
21486
|
`;
|
|
21339
|
-
|
|
21340
|
-
|
|
21341
|
-
${logDataDetail(value, `${prefix} `)}
|
|
21487
|
+
} else if (typeof value === "object") {
|
|
21488
|
+
result += `
|
|
21489
|
+
${logDataDetail(value, `${prefix} `)}
|
|
21342
21490
|
`;
|
|
21343
|
-
|
|
21344
|
-
|
|
21491
|
+
} else {
|
|
21492
|
+
result += `${value}
|
|
21345
21493
|
`;
|
|
21494
|
+
}
|
|
21346
21495
|
}
|
|
21347
21496
|
}
|
|
21348
21497
|
}
|
|
21498
|
+
return result.trim();
|
|
21349
21499
|
}
|
|
21350
|
-
|
|
21351
|
-
}
|
|
21352
|
-
function header(title, padding = 0) {
|
|
21353
|
-
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
21500
|
+
function header(title, padding = 0) {
|
|
21501
|
+
return `${" ".repeat(padding)}${"=".repeat(80)}
|
|
21354
21502
|
${" ".repeat(40 - title.length / 2)}${title}
|
|
21355
21503
|
${" ".repeat(padding)}${"=".repeat(80)}`;
|
|
21356
|
-
}
|
|
21357
|
-
function
|
|
21358
|
-
|
|
21359
|
-
|
|
21360
|
-
|
|
21361
|
-
|
|
21362
|
-
const
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21504
|
+
}
|
|
21505
|
+
function logHeader(title) {
|
|
21506
|
+
logInfo3(`${header(title, 2)}`);
|
|
21507
|
+
}
|
|
21508
|
+
function logDataObject2(title, ...args) {
|
|
21509
|
+
const stack = new Error().stack?.split("\n")[2] || "";
|
|
21510
|
+
const stackMatch = stack.match(/\((.*):(\d+):(\d+)\)$/) || stack.match(/at (.*):(\d+):(\d+)$/);
|
|
21511
|
+
let callerDetails = "";
|
|
21512
|
+
if (stackMatch) {
|
|
21513
|
+
const functionMatch = stack.match(/at (.+) \(/);
|
|
21514
|
+
const functionName = functionMatch ? functionMatch[1] : "<anonymous>";
|
|
21515
|
+
callerDetails = `${functionName}`;
|
|
21516
|
+
}
|
|
21517
|
+
logDetail2(`${header(`*${title}* ${callerDetails}`)}
|
|
21367
21518
|
${args.reduce((acc, arg) => `${acc}
|
|
21368
21519
|
${logDataDetail(arg)}`, "")}
|
|
21369
|
-
|
|
21520
|
+
|
|
21370
21521
|
${"=".repeat(80)}`);
|
|
21371
|
-
}
|
|
21372
|
-
function logErrorObject(error, extraDetails) {
|
|
21373
|
-
if (error instanceof Error) {
|
|
21374
|
-
logError2(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
21375
|
-
Error Message:
|
|
21376
|
-
${error.message}
|
|
21377
|
-
Error Stack:
|
|
21378
|
-
${error.stack}
|
|
21379
|
-
${"=".repeat(80)}`);
|
|
21380
|
-
} else {
|
|
21381
|
-
logError2(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
21382
|
-
${"=".repeat(80)}`);
|
|
21383
21522
|
}
|
|
21523
|
+
function logErrorObject2(error, extraDetails) {
|
|
21524
|
+
if (error instanceof Error) {
|
|
21525
|
+
logError2(`${extraDetails ? header(extraDetails, 1) : header(error.message, 1)}
|
|
21526
|
+
Error Message:
|
|
21527
|
+
${error.message}
|
|
21528
|
+
Error Stack:
|
|
21529
|
+
${error.stack}
|
|
21530
|
+
${"=".repeat(80)}`);
|
|
21531
|
+
} else {
|
|
21532
|
+
logError2(`${extraDetails ? header(extraDetails, 1) : header(String(error), 1)}
|
|
21533
|
+
${"=".repeat(80)}`);
|
|
21534
|
+
}
|
|
21535
|
+
}
|
|
21536
|
+
return {
|
|
21537
|
+
logInfo: logInfo3,
|
|
21538
|
+
logTask,
|
|
21539
|
+
logError: logError2,
|
|
21540
|
+
logDetail: logDetail2,
|
|
21541
|
+
logDebug,
|
|
21542
|
+
logWarning,
|
|
21543
|
+
logColor,
|
|
21544
|
+
setColors,
|
|
21545
|
+
printColors,
|
|
21546
|
+
logHeader,
|
|
21547
|
+
logDataObject: logDataObject2,
|
|
21548
|
+
logErrorObject: logErrorObject2,
|
|
21549
|
+
setLogLevel,
|
|
21550
|
+
setNamespace
|
|
21551
|
+
};
|
|
21384
21552
|
}
|
|
21385
21553
|
|
|
21386
21554
|
// ../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist-node/stringify.js
|
|
@@ -21480,6 +21648,7 @@ async function deletePendingEvents(filePath) {
|
|
|
21480
21648
|
}
|
|
21481
21649
|
|
|
21482
21650
|
// src/logic/logClient.ts
|
|
21651
|
+
var { logInfo: logInfo2, logError, logErrorObject, logDetail, logDataObject } = createLoggers2("logging");
|
|
21483
21652
|
var LogClient = class {
|
|
21484
21653
|
credentials;
|
|
21485
21654
|
loggingClient;
|
|
@@ -21493,8 +21662,6 @@ var LogClient = class {
|
|
|
21493
21662
|
sendInProgress = false;
|
|
21494
21663
|
schedulerStarted = false;
|
|
21495
21664
|
async init() {
|
|
21496
|
-
setLogLevel2(process.env.LOG_LEVEL ?? "none");
|
|
21497
|
-
logNamespace2("logging");
|
|
21498
21665
|
if (typeof this.timeBetweenLogMs !== "number") {
|
|
21499
21666
|
const DEFAULT_TIME_BETWEEN_LOG_MS = 10 * 60 * 1e3;
|
|
21500
21667
|
const DEFAULT_MAX_OFFLINE_TIME_MS = 60 * 60 * 1e3;
|
|
@@ -21523,7 +21690,7 @@ var LogClient = class {
|
|
|
21523
21690
|
const tokenData = await fs.readFile(tokenFilePath, "utf-8");
|
|
21524
21691
|
tokenFile = JSON.parse(tokenData);
|
|
21525
21692
|
logInfo2(`Loaded token from temp file: ${tokenFilePath}`);
|
|
21526
|
-
|
|
21693
|
+
logDetail(
|
|
21527
21694
|
`Token will expire ${(tokenFile.time + tokenFile.token.expiresIn * 1e3 - Date.now()) / (1e3 * 60)} minutes`
|
|
21528
21695
|
);
|
|
21529
21696
|
} catch (_error) {
|
|
@@ -21557,7 +21724,7 @@ var LogClient = class {
|
|
|
21557
21724
|
this.loggingClient = new import_gql_logging_client.default(loggingApi, token.accessToken);
|
|
21558
21725
|
this.initialized = true;
|
|
21559
21726
|
} else {
|
|
21560
|
-
|
|
21727
|
+
logError("Check your internet connection - token not found");
|
|
21561
21728
|
}
|
|
21562
21729
|
if (!this.schedulerStarted) {
|
|
21563
21730
|
this.schedulerStarted = true;
|
|
@@ -21613,7 +21780,7 @@ var LogClient = class {
|
|
|
21613
21780
|
this.firstOfflineTime = void 0;
|
|
21614
21781
|
logInfo2(`Logging batch result: ${batch.length} events sent`);
|
|
21615
21782
|
} catch (error) {
|
|
21616
|
-
|
|
21783
|
+
logError("Send batch failed", error);
|
|
21617
21784
|
if (this.firstOfflineTime === void 0) {
|
|
21618
21785
|
this.firstOfflineTime = Date.now();
|
|
21619
21786
|
}
|