@xylabs/logger
Advanced tools
Comparing version 2.13.4 to 2.13.5
// src/Logger.ts | ||
var LoggerStub = 1; | ||
import { handleError } from "@xylabs/error"; | ||
var getFunctionName = (depth = 2) => { | ||
try { | ||
throw Error(); | ||
} catch (ex) { | ||
return handleError(ex, (error) => { | ||
let newIndex = void 0; | ||
const stackParts = error.stack?.split("\n")[depth].split(" "); | ||
const funcName = stackParts?.find((item, index) => { | ||
if (item.length > 0 && item !== "at") { | ||
if (item === "new") { | ||
newIndex = index; | ||
} | ||
return item; | ||
} | ||
}) ?? "<unknown>"; | ||
return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName; | ||
}); | ||
} | ||
}; | ||
export { | ||
LoggerStub | ||
getFunctionName | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -13,3 +13,3 @@ export type LogFunction = (message?: unknown) => void; | ||
} | ||
export declare const LoggerStub = 1; | ||
export declare const getFunctionName: (depth?: number) => string; | ||
//# sourceMappingURL=Logger.d.ts.map |
// src/Logger.ts | ||
var LoggerStub = 1; | ||
import { handleError } from "@xylabs/error"; | ||
var getFunctionName = (depth = 2) => { | ||
try { | ||
throw Error(); | ||
} catch (ex) { | ||
return handleError(ex, (error) => { | ||
var _a; | ||
let newIndex = void 0; | ||
const stackParts = (_a = error.stack) == null ? void 0 : _a.split("\n")[depth].split(" "); | ||
const funcName = (stackParts == null ? void 0 : stackParts.find((item, index) => { | ||
if (item.length > 0 && item !== "at") { | ||
if (item === "new") { | ||
newIndex = index; | ||
} | ||
return item; | ||
} | ||
})) ?? "<unknown>"; | ||
return newIndex ? `${funcName} ${stackParts == null ? void 0 : stackParts[newIndex + 1]}` : funcName; | ||
}); | ||
} | ||
}; | ||
export { | ||
LoggerStub | ||
getFunctionName | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -13,3 +13,3 @@ export type LogFunction = (message?: unknown) => void; | ||
} | ||
export declare const LoggerStub = 1; | ||
export declare const getFunctionName: (depth?: number) => string; | ||
//# sourceMappingURL=Logger.d.ts.map |
@@ -13,2 +13,5 @@ { | ||
"description": "Primary SDK for using XYO Protocol 2.0", | ||
"dependencies": { | ||
"@xylabs/error": "~2.13.5" | ||
}, | ||
"devDependencies": { | ||
@@ -57,4 +60,4 @@ "@xylabs/ts-scripts-yarn3": "^3.1.21", | ||
"sideEffects": false, | ||
"version": "2.13.4", | ||
"version": "2.13.5", | ||
"type": "module" | ||
} |
@@ -0,1 +1,3 @@ | ||
import { handleError } from '@xylabs/error' | ||
export type LogFunction = (message?: unknown) => void | ||
@@ -15,3 +17,22 @@ | ||
//to satisfy export | ||
export const LoggerStub = 1 | ||
export const getFunctionName = (depth = 2) => { | ||
try { | ||
throw Error() | ||
} catch (ex) { | ||
return handleError(ex, (error) => { | ||
let newIndex: number | undefined = undefined | ||
const stackParts = error.stack?.split('\n')[depth].split(' ') | ||
const funcName = | ||
stackParts?.find((item, index) => { | ||
if (item.length > 0 && item !== 'at') { | ||
//check if constructor | ||
if (item === 'new') { | ||
newIndex = index | ||
} | ||
return item | ||
} | ||
}) ?? '<unknown>' | ||
return newIndex ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName | ||
}) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36094
52
272
1
+ Added@xylabs/error@~2.13.5
+ Added@xylabs/error@2.13.30(transitive)