Skip to content

Commit

Permalink
feat: make get_log_level available to plugin, respect log level
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice committed Aug 30, 2024
1 parent b4aba72 commit 9d1cdb2
Show file tree
Hide file tree
Showing 8 changed files with 756 additions and 334 deletions.
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

0 comments on commit 9d1cdb2

Please sign in to comment.