@putkoff/abstract-logger 0.0.41 → 0.0.46
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 +30 -13
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/config.d.ts +1 -0
- package/dist/esm/index.js +30 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/config.d.ts +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -187,10 +187,6 @@ const COLS = {
|
|
|
187
187
|
/* ------------------------------------------------------------------ */
|
|
188
188
|
/* Winston logger (Node only) */
|
|
189
189
|
/* ------------------------------------------------------------------ */
|
|
190
|
-
console.log("ENV CHECK:", {
|
|
191
|
-
LOG_SHOW_DETAILS: process.env.LOG_SHOW_DETAILS,
|
|
192
|
-
LOG_DETAILS_ALLOWLIST: process.env.LOG_DETAILS_ALLOWLIST,
|
|
193
|
-
});
|
|
194
190
|
function getLogConfig() {
|
|
195
191
|
return {
|
|
196
192
|
condensed: process.env.LOG_CONDENSED !== "false",
|
|
@@ -213,6 +209,17 @@ function getLogConfig() {
|
|
|
213
209
|
: [],
|
|
214
210
|
};
|
|
215
211
|
}
|
|
212
|
+
function debugLogConfig() {
|
|
213
|
+
if (process.env.LOG_DEBUG_CONFIG === "true") {
|
|
214
|
+
console.log("LOG CONFIG ENV:", {
|
|
215
|
+
LOG_SHOW_DETAILS: process.env.LOG_SHOW_DETAILS,
|
|
216
|
+
LOG_DETAILS_ALLOWLIST: process.env.LOG_DETAILS_ALLOWLIST,
|
|
217
|
+
LOG_PRETTY_DETAILS: process.env.LOG_PRETTY_DETAILS,
|
|
218
|
+
LOG_CONDENSED: process.env.LOG_CONDENSED,
|
|
219
|
+
LOG_EXPAND_DEBUG: process.env.LOG_EXPAND_DEBUG,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
216
223
|
function parse$1(v) {
|
|
217
224
|
return v ? v.split(",").map(s => s.trim()) : [];
|
|
218
225
|
}
|
|
@@ -14820,12 +14827,13 @@ function hash(str) {
|
|
|
14820
14827
|
}
|
|
14821
14828
|
function shouldLog(opts, caller) {
|
|
14822
14829
|
const cfg = getLogConfig();
|
|
14830
|
+
// logType is already normalized upstream
|
|
14831
|
+
const type = opts.logType;
|
|
14823
14832
|
const fn = caller.functionName;
|
|
14824
|
-
const type = opts.logType ?? "info";
|
|
14825
14833
|
const activity = opts.activity;
|
|
14826
14834
|
const message = opts.message;
|
|
14827
14835
|
// ─────────────────────────────────────
|
|
14828
|
-
// 1️⃣ Hard allowlist
|
|
14836
|
+
// 1️⃣ Hard allowlist
|
|
14829
14837
|
// ─────────────────────────────────────
|
|
14830
14838
|
if (cfg.functionAllowlist.length > 0) {
|
|
14831
14839
|
if (!cfg.functionAllowlist.includes(fn))
|
|
@@ -14841,17 +14849,17 @@ function shouldLog(opts, caller) {
|
|
|
14841
14849
|
if (cfg.logTypeBlocklist.includes(type))
|
|
14842
14850
|
return false;
|
|
14843
14851
|
// ─────────────────────────────────────
|
|
14844
|
-
// 3️⃣ Burst protection (debug
|
|
14852
|
+
// 3️⃣ Burst protection (debug)
|
|
14845
14853
|
// ─────────────────────────────────────
|
|
14846
14854
|
if (type === "debug") {
|
|
14847
14855
|
const key = fn + ":" + message;
|
|
14848
14856
|
const count = (seen.get(key) ?? 0) + 1;
|
|
14849
14857
|
seen.set(key, count);
|
|
14850
14858
|
if (count > 5)
|
|
14851
|
-
return false;
|
|
14859
|
+
return false;
|
|
14852
14860
|
}
|
|
14853
14861
|
// ─────────────────────────────────────
|
|
14854
|
-
// 4️⃣
|
|
14862
|
+
// 4️⃣ Sampling
|
|
14855
14863
|
// ─────────────────────────────────────
|
|
14856
14864
|
if (cfg.sampleRate < 1) {
|
|
14857
14865
|
const pct = (hash(fn) % 100) / 100;
|
|
@@ -14877,16 +14885,24 @@ function getLogString(messageOrOptions, logType = null, details = null, function
|
|
|
14877
14885
|
};
|
|
14878
14886
|
let { message, logType: resolvedLogType, details: resolvedDetails, function_name: resolvedFunctionName, file_location: resolvedFileLocation, consumerLogger: resolvedLoggerInput, } = opts;
|
|
14879
14887
|
/* -------------------------------------------------- */
|
|
14880
|
-
/* Caller
|
|
14888
|
+
/* Caller info */
|
|
14881
14889
|
/* -------------------------------------------------- */
|
|
14882
14890
|
const caller = getCallerInfo(getLogString);
|
|
14891
|
+
/* -------------------------------------------------- */
|
|
14892
|
+
/* 🔒 Single source of truth for logType */
|
|
14893
|
+
/* -------------------------------------------------- */
|
|
14894
|
+
const finalLogType = resolvedLogType ?? "info";
|
|
14895
|
+
// 🔒 overwrite raw input so downstream never guesses
|
|
14896
|
+
opts.logType = finalLogType;
|
|
14897
|
+
/* -------------------------------------------------- */
|
|
14898
|
+
/* Blocking */
|
|
14899
|
+
/* -------------------------------------------------- */
|
|
14883
14900
|
if (!shouldLog(opts, caller)) {
|
|
14884
14901
|
return "";
|
|
14885
14902
|
}
|
|
14886
14903
|
/* -------------------------------------------------- */
|
|
14887
|
-
/*
|
|
14904
|
+
/* Resolve names */
|
|
14888
14905
|
/* -------------------------------------------------- */
|
|
14889
|
-
const finalLogType = resolvedLogType ?? "info";
|
|
14890
14906
|
resolvedFunctionName = resolveValue(resolvedFunctionName, caller.functionName);
|
|
14891
14907
|
resolvedFileLocation = resolveValue(resolvedFileLocation, caller.file);
|
|
14892
14908
|
/* -------------------------------------------------- */
|
|
@@ -14917,7 +14933,7 @@ function getLogString(messageOrOptions, logType = null, details = null, function
|
|
|
14917
14933
|
file: resolvedFileLocation,
|
|
14918
14934
|
condense,
|
|
14919
14935
|
maxDetailsLength: LOG_CONFIG.maxDetailsLength,
|
|
14920
|
-
pretty,
|
|
14936
|
+
pretty,
|
|
14921
14937
|
}), finalLogType, resolvedLoggerInput);
|
|
14922
14938
|
}
|
|
14923
14939
|
|
|
@@ -14925,6 +14941,7 @@ exports.COLS = COLS;
|
|
|
14925
14941
|
exports.IS_BROWSER = IS_BROWSER;
|
|
14926
14942
|
exports.IS_NODE = IS_NODE;
|
|
14927
14943
|
exports.activityEmojiMap = activityEmojiMap;
|
|
14944
|
+
exports.debugLogConfig = debugLogConfig;
|
|
14928
14945
|
exports.extractFile = extractFile;
|
|
14929
14946
|
exports.formatLogLine = formatLogLine;
|
|
14930
14947
|
exports.getCallerInfo = getCallerInfo;
|