@putkoff/abstract-logger 0.0.24 → 0.0.28
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/cjs/index.js +31 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/config.d.ts +3 -6
- package/dist/cjs/types/logger/logger.d.ts +1 -1
- package/dist/esm/index.js +31 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/config.d.ts +3 -6
- package/dist/esm/types/logger/logger.d.ts +1 -1
- package/dist/types/config.d.ts +3 -6
- package/dist/types/index.d.ts +5 -8
- package/dist/types/logger/logger.d.ts +1 -1
- package/package.json +6 -5
package/dist/cjs/index.js
CHANGED
|
@@ -14469,22 +14469,22 @@ const IS_BROWSER = typeof window !== "undefined" &&
|
|
|
14469
14469
|
const IS_NODE = typeof process !== "undefined" &&
|
|
14470
14470
|
process.release?.name === "node";
|
|
14471
14471
|
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
:
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
}
|
|
14472
|
+
function parseList(value) {
|
|
14473
|
+
return value
|
|
14474
|
+
? value.split(",").map(s => s.trim()).filter(Boolean)
|
|
14475
|
+
: [];
|
|
14476
|
+
}
|
|
14477
|
+
function getLogConfig() {
|
|
14478
|
+
return {
|
|
14479
|
+
condensed: process.env.LOG_CONDENSED !== "false",
|
|
14480
|
+
expandOnDebug: process.env.LOG_EXPAND_DEBUG !== "false",
|
|
14481
|
+
showDetails: process.env.LOG_SHOW_DETAILS !== "false",
|
|
14482
|
+
maxDetailsLength: Number(process.env.LOG_DETAILS_MAX ?? 500),
|
|
14483
|
+
showDetailslist: parseList(process.env.LOG_DETAILS_ALLOWLIST),
|
|
14484
|
+
functionAllowlist: parseList(process.env.LOG_FUNCTION_ALLOWLIST),
|
|
14485
|
+
functionBlocklist: parseList(process.env.LOG_FUNCTION_BLOCKLIST),
|
|
14486
|
+
};
|
|
14487
|
+
}
|
|
14488
14488
|
|
|
14489
14489
|
/* ------------------------------------------------------------------ */
|
|
14490
14490
|
/* Winston logger (Node only) */
|
|
@@ -14504,11 +14504,22 @@ if (IS_NODE) {
|
|
|
14504
14504
|
});
|
|
14505
14505
|
}
|
|
14506
14506
|
function shouldCondense(logType) {
|
|
14507
|
+
const LOG_CONFIG = getLogConfig();
|
|
14507
14508
|
if (LOG_CONFIG.expandOnDebug && logType === "debug") {
|
|
14508
14509
|
return false;
|
|
14509
14510
|
}
|
|
14510
14511
|
return LOG_CONFIG.condensed;
|
|
14511
14512
|
}
|
|
14513
|
+
function shouldShowDetails(logType) {
|
|
14514
|
+
const LOG_CONFIG = getLogConfig();
|
|
14515
|
+
const allow = LOG_CONFIG.showDetailslist;
|
|
14516
|
+
// If allowlist exists, it RESTRICTS
|
|
14517
|
+
if (allow.length > 0) {
|
|
14518
|
+
return allow.includes(logType);
|
|
14519
|
+
}
|
|
14520
|
+
// Otherwise fall back to global flag
|
|
14521
|
+
return LOG_CONFIG.showDetails;
|
|
14522
|
+
}
|
|
14512
14523
|
/** Exported logger */
|
|
14513
14524
|
const logger = nodeLogger;
|
|
14514
14525
|
/**
|
|
@@ -14667,12 +14678,14 @@ function getLogString(messageOrOptions, logType = null, details = null, function
|
|
|
14667
14678
|
const emoji = emojiMap[finalLogType] ?? "ℹ️";
|
|
14668
14679
|
const timestamp = new Date().toISOString();
|
|
14669
14680
|
const condense = shouldCondense(finalLogType);
|
|
14681
|
+
const showDetails = shouldShowDetails(finalLogType);
|
|
14670
14682
|
if (condense) {
|
|
14671
14683
|
resolvedFileLocation = resolvedFileLocation.split("/").pop();
|
|
14672
14684
|
}
|
|
14673
14685
|
let line = `${emoji} [${timestamp}] [${resolvedFunctionName}] ${message}`;
|
|
14674
14686
|
// ---------------- Details serialization ----------------
|
|
14675
|
-
if (resolvedDetails !== null && resolvedDetails !== undefined) {
|
|
14687
|
+
if (showDetails && resolvedDetails !== null && resolvedDetails !== undefined) {
|
|
14688
|
+
const LOG_CONFIG = getLogConfig();
|
|
14676
14689
|
const serialized = serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength);
|
|
14677
14690
|
line += ` | ${serialized}`;
|
|
14678
14691
|
}
|
|
@@ -14717,7 +14730,7 @@ function getLogString(messageOrOptions, logType = null, details = null, function
|
|
|
14717
14730
|
|
|
14718
14731
|
exports.IS_BROWSER = IS_BROWSER;
|
|
14719
14732
|
exports.IS_NODE = IS_NODE;
|
|
14720
|
-
exports.
|
|
14733
|
+
exports.getLogConfig = getLogConfig;
|
|
14721
14734
|
exports.getLogString = getLogString;
|
|
14722
14735
|
exports.logger = logger;
|
|
14723
14736
|
exports.resolveValue = resolveValue;
|