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

Allow logger to work in browser #1620

Merged
merged 7 commits into from
Jan 17, 2025
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
2 changes: 1 addition & 1 deletion demos/client-bundle-example/src/frictionless.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Procaptcha demo: Live Test</title>
<script type="module">
async function captchaLoaded() {
const render = (await import('./assets/procaptcha.bundle')).render
const render = (await import('./assets/procaptcha.bundle.js')).render
console.log('Captcha loaded')
// Get the Element using elementId
const captchaContainer = document.getElementById('procaptcha-container')
Expand Down
2 changes: 1 addition & 1 deletion demos/client-bundle-example/src/urlParams.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Procaptcha demo: Live Test</title>
<script type="module">
async function captchaLoaded() {
const render = (await import('./assets/procaptcha.bundle')).render
const render = (await import('./assets/procaptcha.bundle.js')).render
console.log('Captcha loaded')
// Get the Element using elementId
const captchaContainer = document.getElementById('procaptcha-container')
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default (
return {
command: "version",
describe: "Return the version of the software",
handler: async () => {
handler: () => {
logger.info(`Version: ${JSON.stringify(version)}`);
},
};
Expand Down
11 changes: 9 additions & 2 deletions packages/common/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ const JSONReporter = (
options: ConsolaOptions;
},
) => {
// https://stackoverflow.com/a/65886224
const writer = process?.stdout
? process.stdout.write.bind(process.stdout)
: console.info;
const writerError = process?.stderr
? process.stderr.write.bind(process.stderr)
: console.error;
if (context.options.level === ConsolaLogLevels.error) {
process.stderr.write(`${JSON.stringify(message)}\n`);
writerError(`${JSON.stringify(message)}\n`);
} else {
process.stdout.write(`${JSON.stringify(message)}\n`);
writer(`${JSON.stringify(message)}\n`);
}
};

Expand Down
Loading