cleanup: use debug logging instead of info in runtime, fix C example (#214)

This commit is contained in:
zach
2023-01-15 17:16:29 -08:00
committed by GitHub
parent 081c825cd8
commit a1f36c58d2
7 changed files with 13 additions and 12 deletions

View File

@@ -1,2 +1,2 @@
build:
clang -o main main.c -lextism -L .
clang -g -o main main.c -lextism -L .

View File

@@ -9,9 +9,9 @@
#include <sys/stat.h>
#include <unistd.h>
void hello_world(ExtismCurrentPlugin *plugin, const struct ExtismVal *inputs,
uint64_t n_inputs, struct ExtismVal *outputs,
uint64_t n_outputs, void *data) {
void hello_world(ExtismCurrentPlugin *plugin, const ExtismVal *inputs,
uint64_t n_inputs, ExtismVal *outputs, uint64_t n_outputs,
void *data) {
puts("Hello from C!");
puts(data);
@@ -61,7 +61,8 @@ int main(int argc, char *argv[]) {
ExtismValType outputs[] = {I64};
ExtismFunction *f = extism_function_new("hello_world", inputs, 1, outputs, 1,
hello_world, "Hello, again!", NULL);
ExtismPlugin plugin = extism_plugin_new(ctx, data, len, &f, 1, true);
ExtismPlugin plugin =
extism_plugin_new(ctx, data, len, (const ExtismFunction **)&f, 1, true);
free(data);
if (plugin < 0) {
puts(extism_error(ctx, -1));

View File

@@ -42,5 +42,5 @@ withContext(async function (context) {
// or, use a context like this:
// let ctx = new Context();
// let wasm = readFileSync("../wasm/code.wasm");
// let p = ctx.plugin(wasm, wasi = true);
// let p = ctx.plugin(wasm);
// ... where the context can be passed around to various functions etc.

View File

@@ -173,7 +173,7 @@ impl PluginMemory {
pages_needed = 1
}
info!("Requesting {pages_needed} more pages");
debug!("Requesting {pages_needed} more pages");
// This will fail if we've already allocated the maximum amount of memory allowed
self.memory.grow(&mut self.store, pages_needed)?;
}
@@ -183,7 +183,7 @@ impl PluginMemory {
length: n,
};
info!(
debug!(
"Allocated new block: {} bytes at offset {}",
mem.length, mem.offset
);
@@ -202,7 +202,7 @@ impl PluginMemory {
/// Free the block allocated at `offset`
pub fn free(&mut self, offset: usize) {
info!("Freeing block at {offset}");
debug!("Freeing block at {offset}");
if let Some(length) = self.live_blocks.remove(&offset) {
self.free.push(MemoryBlock { offset, length });
} else {

View File

@@ -356,7 +356,7 @@ impl Runtime {
&[Val::I32(0), Val::I32(0)],
results.as_mut_slice(),
)?;
info!("Initialized Haskell language runtime");
debug!("Initialized Haskell language runtime");
}
}
Ok(())
@@ -370,7 +370,7 @@ impl Runtime {
let mut results =
vec![Val::null(); cleanup.ty(&plugin.memory.store).results().len()];
cleanup.call(&mut plugin.memory.store, &[], results.as_mut_slice())?;
info!("Cleaned up Haskell language runtime");
debug!("Cleaned up Haskell language runtime");
}
}

View File

@@ -331,7 +331,7 @@ pub unsafe extern "C" fn extism_plugin_update(
ctx.plugins
.insert(index, std::cell::UnsafeCell::new(plugin));
info!("Plugin updated: {index}");
debug!("Plugin updated: {index}");
true
}

Binary file not shown.