-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
intial integration of TopoViewer via git-submodule
- Loading branch information
1 parent
699350b
commit edd51c8
Showing
13 changed files
with
4,269 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "src/topoViewer/webview-ui"] | ||
path = src/topoViewer/webview-ui | ||
url = https://github.com/asadarafat/topoViewer.git |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// file: src/logger.ts | ||
|
||
|
||
// aarafat-tag: | ||
// This is custom logger to provide the following log entry: | ||
// time=2024-12-29T09:37:21Z level=info msg=Hello file=topoViewer.ts:108 | ||
// the objective is to provide quick code tracing during debugging. Im open to suggestion if there is better way to do the objective as long as not using heavy library. | ||
|
||
import * as vscode from 'vscode'; | ||
|
||
/** | ||
* Create a single OutputChannel for logs. | ||
*/ | ||
const outputChannel = vscode.window.createOutputChannel("TopoViewer Logs"); | ||
|
||
/** | ||
* Extract file name + line number from the call stack. | ||
* We'll parse compiled `.js` stack frames, | ||
* which may differ slightly from your TypeScript lines. | ||
*/ | ||
function getCallerFileLine(): string { | ||
const obj = {}; | ||
Error.captureStackTrace(obj, getCallerFileLine); | ||
|
||
const stack = (obj as any).stack as string; | ||
if (!stack) return 'unknown:0'; | ||
|
||
const lines = stack.split('\n'); | ||
// Typically, index 3 or 4 is the real caller | ||
const callSite = lines[3] || lines[4] || ''; | ||
|
||
const match = callSite.match(/\((.*?):(\d+):\d+\)/) | ||
|| callSite.match(/at (.*?):(\d+):\d+/); | ||
if (!match) return 'unknown:0'; | ||
|
||
const filePath = match[1]; // e.g. /path/to/out/topoViewer.js | ||
const lineNum = match[2]; // e.g. 108 | ||
|
||
// Extract just the file name from the path | ||
const fileName = filePath.split(/[\\/]/).pop() ?? 'unknown'; | ||
return `${fileName}:${lineNum}`; | ||
} | ||
|
||
/** | ||
* Logs a formatted message to the OutputChannel. | ||
* | ||
* @param level "info", "debug", "warn", "error", etc. | ||
* @param message The log message to display | ||
*/ | ||
function logMessage(level: string, message: string): void { | ||
const now = new Date().toISOString(); // e.g. 2024-12-29T09:37:21.000Z | ||
const fileLine = getCallerFileLine(); // e.g. "topoViewer.ts:108" | ||
|
||
// Final log line: | ||
// time=2024-12-29T09:37:21Z level=info msg=Hello file=topoViewer.ts:108 | ||
const logLine = `time=${now} level=${level} msg=${message} file=${fileLine}`; | ||
|
||
// Write to the OutputChannel | ||
outputChannel.appendLine(logLine); | ||
|
||
// If you want to auto-show the channel: | ||
// outputChannel.show(true); | ||
} | ||
|
||
/** | ||
* Export a `log` object with convenience methods. | ||
*/ | ||
export const log = { | ||
info(msg: string) { logMessage('info', msg); }, | ||
debug(msg: string) { logMessage('debug', msg); }, | ||
warn(msg: string) { logMessage('warn', msg); }, | ||
error(msg: string) { logMessage('error', msg); }, | ||
}; |
Oops, something went wrong.