MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / getCallerFile

Method getCallerFile

lib/logger.ts:47–68  ·  view source on GitHub ↗
(skipFrames: number = 3)

Source from the content-addressed store, hash-verified

45 }
46
47 private getCallerFile(skipFrames: number = 3): string {
48 const originalPrepareStackTrace = Error.prepareStackTrace
49 try {
50 const err = new Error()
51 Error.prepareStackTrace = (_, stack) => stack
52 const stack = err.stack as unknown as NodeJS.CallSite[]
53 Error.prepareStackTrace = originalPrepareStackTrace
54
55 // Skip specified number of frames to get to actual caller
56 for (let i = skipFrames; i < stack.length; i++) {
57 const filename = stack[i]?.getFileName()
58 if (filename && !filename.includes("/logger.")) {
59 // Extract just the filename without path and extension
60 const match = filename.match(/([^/\\]+)\.[tj]s$/)
61 return match ? match[1] : filename
62 }
63 }
64 return "unknown"
65 } catch {
66 return "unknown"
67 }
68 }
69
70 private async write(level: string, component: string, message: string, data?: any) {
71 if (!this.enabled) return

Callers 4

infoMethod · 0.95
debugMethod · 0.95
warnMethod · 0.95
errorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected