Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support loglevel filter in playground #3569

Merged
merged 7 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chronus/changes/playground-log-2024-5-12-13-33-41.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/playground"
---

Support loglevel in playground's logging
27 changes: 25 additions & 2 deletions packages/playground/src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,31 @@ export async function registerMonacoLanguage(host: BrowserHost) {
return model ? textDocumentForModel(model) : undefined;
},
sendDiagnostics() {},
// eslint-disable-next-line no-console
log: console.log,
log: (log) => {
switch (log.level) {
case "error":
// eslint-disable-next-line no-console
console.error(log);
break;
case "warning":
// eslint-disable-next-line no-console
console.warn(log);
break;
case "info":
// eslint-disable-next-line no-console
console.info(log);
break;
case "debug":
// corresponding to Verbose LogLevel in Edge/Chrome which is off by default
// eslint-disable-next-line no-console
console.debug(log);
break;
case "trace":
default:
// just skip traces in playground
break;
}
},
applyEdit(param) {
return Promise.resolve({ applied: false });
},
Expand Down
Loading