Skip to content

Commit 30a15c6

Browse files
feat(Wind): Add short mode to DevLog and mark output as fire-and-forget
Add `short` mode to DevLog utility that compresses long app-data paths to `$APP` alias and deduplicates consecutive identical messages with `(xN)` suffix. This reduces log noise during development when debugging extension host IPC. Also add `output` to FireAndForgetChannels since VS Code output channels are managed by Mountain natively; browser-side stat/writeFile for output_* log files are not needed.
1 parent 2685799 commit 30a15c6

3 files changed

Lines changed: 107 additions & 26 deletions

File tree

Source/Function/DevLog.ts

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* ```js
99
* window.__LAND_DEV_LOG = "vfs,ipc"; // only VFS + IPC
1010
* window.__LAND_DEV_LOG = "all"; // everything
11+
* window.__LAND_DEV_LOG = "short"; // everything, compressed + deduped
1112
* delete window.__LAND_DEV_LOG; // off (default)
1213
* ```
1314
*
@@ -16,6 +17,13 @@
1617
* localStorage.setItem("LAND_DEV_LOG", "config,folder");
1718
* ```
1819
*
20+
* ## Short Mode
21+
*
22+
* `LAND_DEV_LOG=short` enables all tags with compression:
23+
* - Long app-data paths aliased to `$APP`
24+
* - Consecutive duplicate messages counted (`(x14)` suffix)
25+
* - Clean single-line output
26+
*
1927
* ## Tags — Mountain (Rust) + Wind/Sky (TypeScript)
2028
*
2129
* | Tag | Scope |
@@ -57,7 +65,10 @@
5765
* | `preload` | Preload: globals, polyfills, ipcRenderer |
5866
*/
5967

68+
// ── Tag resolution ──────────────────────────────────────────────────────
69+
6070
let CachedTags: string[] | null = null;
71+
let CachedShort: boolean | null = null;
6172

6273
const GetEnabledTags = (): string[] => {
6374
if (CachedTags !== null) return CachedTags;
@@ -74,13 +85,43 @@ const GetEnabledTags = (): string[] => {
7485
return CachedTags;
7586
};
7687

88+
const IsShort = (): boolean => {
89+
if (CachedShort !== null) return CachedShort;
90+
CachedShort = GetEnabledTags().includes("short");
91+
return CachedShort;
92+
};
93+
7794
const IsEnabled = (Tag: string): boolean => {
7895
const Tags = GetEnabledTags();
7996
if (Tags.length === 0) return false;
97+
if (IsShort()) return true;
8098
const Lower = Tag.toLowerCase();
8199
return Tags.some((T) => T === "all" || T === Lower);
82100
};
83101

102+
// ── Path alias ──────────────────────────────────────────────────────────
103+
// The app-data directory name can be 100+ chars. Alias to $APP.
104+
105+
const AppDataPattern = /land\.editor\.binary\.[^\s/\\)]+/g;
106+
107+
const AliasPath = (Input: string): string =>
108+
Input.replace(AppDataPattern, "$APP");
109+
110+
// ── Dedup buffer ────────────────────────────────────────────────────────
111+
112+
let DedupKey = "";
113+
let DedupCount = 0;
114+
115+
const FlushDedup = (): void => {
116+
if (DedupCount > 1) {
117+
console.log(` (x${DedupCount})`);
118+
}
119+
DedupKey = "";
120+
DedupCount = 0;
121+
};
122+
123+
// ── Main DevLog function ────────────────────────────────────────────────
124+
84125
/**
85126
* Tagged development log. Only prints if the tag is enabled.
86127
*
@@ -89,14 +130,34 @@ const IsEnabled = (Tag: string): boolean => {
89130
* DevLog("CONFIG", "resolveConfiguration folderUri:", folderUri);
90131
*/
91132
const DevLog = (Tag: string, ...Args: unknown[]): void => {
92-
if (IsEnabled(Tag)) {
93-
console.log(`[DEV:${Tag.toUpperCase()}]`, ...Args);
133+
if (!IsEnabled(Tag)) return;
134+
135+
const TagUpper = Tag.toUpperCase();
136+
137+
if (IsShort()) {
138+
const Message = Args.map(String).join(" ");
139+
const Aliased = AliasPath(Message);
140+
const Key = `${TagUpper}:${Aliased}`;
141+
142+
if (Key === DedupKey) {
143+
DedupCount++;
144+
return;
145+
}
146+
147+
FlushDedup();
148+
DedupKey = Key;
149+
DedupCount = 1;
150+
console.log(`[DEV:${TagUpper}]`, Aliased);
151+
} else {
152+
console.log(`[DEV:${TagUpper}]`, ...Args);
94153
}
95154
};
96155

97156
/** Force-reset the cache (call after changing window.__LAND_DEV_LOG). */
98157
DevLog.reset = () => {
99158
CachedTags = null;
159+
CachedShort = null;
160+
FlushDedup();
100161
};
101162

102163
export default DevLog;

Source/Service/TauriMainProcessService.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,27 @@ import type {
2626

2727
// Inline DevLog — can't import from ../Function/ because this file is served
2828
// from /Static/Application/vs/platform/ipc/ where relative imports break.
29+
const _AppDataPattern = /land\.editor\.binary\.[^\s/\\)]+/g;
30+
let _DedupKey = "";
31+
let _DedupCount = 0;
2932
const DevLog = (Tag: string, ...Args: unknown[]): void => {
3033
const Filter = (window as any).__LAND_DEV_LOG;
3134
if (!Filter) return;
35+
const Filters = String(Filter).split(",").map((T: string) => T.trim().toLowerCase());
36+
const Short = Filters.includes("short");
3237
const Lower = Tag.toLowerCase();
33-
if (
34-
Filter === "all" ||
35-
String(Filter)
36-
.split(",")
37-
.some((T: string) => T.trim().toLowerCase() === Lower)
38-
) {
39-
console.log(`[DEV:${Tag.toUpperCase()}]`, ...Args);
38+
if (!Short && Filter !== "all" && !Filters.includes(Lower)) return;
39+
const TagUpper = Tag.toUpperCase();
40+
if (Short) {
41+
const Message = Args.map(String).join(" ").replace(_AppDataPattern, "$APP");
42+
const Key = `${TagUpper}:${Message}`;
43+
if (Key === _DedupKey) { _DedupCount++; return; }
44+
if (_DedupCount > 1) console.log(` (x${_DedupCount})`);
45+
_DedupKey = Key;
46+
_DedupCount = 1;
47+
console.log(`[DEV:${TagUpper}]`, Message);
48+
} else {
49+
console.log(`[DEV:${TagUpper}]`, ...Args);
4050
}
4151
};
4252

@@ -87,8 +97,11 @@ const ChannelRouteMap: Record<string, string> = {
8797
/**
8898
* Channels where call() can be fire-and-forget (no real response needed).
8999
* Returns undefined immediately instead of going through Tauri.
100+
* - logger: log messages don't need acknowledgement
101+
* - output: VS Code output channels are managed by Mountain natively;
102+
* browser-side stat/writeFile for output_* log files are not needed
90103
*/
91-
const FireAndForgetChannels = new Set(["logger"]);
104+
const FireAndForgetChannels = new Set(["logger", "output"]);
92105

93106
/**
94107
* Channels where errors must be thrown (not swallowed) so VS Code's

Target/Function/Install/Function/Install.js

Lines changed: 23 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)