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

feat: make get_log_level available to plugin, respect log level #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 11 additions & 7 deletions examples/deno.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#!/usr/bin/env deno run -A
import createPlugin from '../src/mod.ts';
import { LogLevelTrace } from "../src/interfaces.ts";
import createPlugin from "../src/mod.ts";

const filename = Deno.args[0] || 'wasm/hello.wasm';
const funcname = Deno.args[1] || 'run_test';
const input = Deno.args[2] || 'this is a test';
const filename = Deno.args[0] || "wasm/hello.wasm";
const funcname = Deno.args[1] || "run_test";
const input = Deno.args[2] || "this is a test";

const plugin = await createPlugin(filename, {
useWasi: true,
logLevel: LogLevelTrace,
logger: console,
config: {
thing: 'testing',
thing: "testing",
},
});

console.log("calling", { filename, funcname, input });
const res = await plugin.call(funcname, new TextEncoder().encode(input));
const s = new TextDecoder().decode(res.buffer);
console.log(s);
// const s = new TextDecoder().decode(res.buffer);
// console.log(s);

await plugin.close();
10 changes: 7 additions & 3 deletions examples/node.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node --no-warnings
/* eslint-disable @typescript-eslint/no-var-requires */
const createPlugin = require('../dist/cjs').default;
const { LogLevelTrace } = require('../dist/cjs');
const { argv } = require('process');

async function main() {
Expand All @@ -10,14 +11,17 @@ async function main() {

const plugin = await createPlugin(filename, {
useWasi: true,
logger: console,
config: { thing: 'testing' },
allowedHosts: ['*.typicode.com'],
runInWorker: true
runInWorker: true,
logLevel: LogLevelTrace,
});

console.log('calling', {filename, funcname, input});
const res = await plugin.call(funcname, new TextEncoder().encode(input));
const s = new TextDecoder().decode(res.buffer);
console.log(s);
// const s = new TextDecoder().decode(res.buffer);
// console.log(s);

await plugin.close();
}
Expand Down
Loading
Loading