Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daneelsan/zig-wasm-logger
A simple implementation of console.log() in Zig + JS + Wasm
https://github.com/daneelsan/zig-wasm-logger
javascript wasm zig
Last synced: 2 months ago
JSON representation
A simple implementation of console.log() in Zig + JS + Wasm
- Host: GitHub
- URL: https://github.com/daneelsan/zig-wasm-logger
- Owner: daneelsan
- Created: 2022-07-13T23:00:28.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-05T23:15:29.000Z (12 months ago)
- Last Synced: 2024-02-06T00:25:07.175Z (12 months ago)
- Topics: javascript, wasm, zig
- Language: Zig
- Homepage:
- Size: 291 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# zig-wasm-logger
A simple implementation of `console.log()` in Zig + JS + Wasm.
https://daneelsan.github.io/zig-wasm-logger/
![example](./example.gif)
## Usage
```zig
const JS = @import("JS.zig");/// Print `args` formatted by `format` into Javascript's console.
JS.Console.log(format, args)
```Example:
```zig
const JS = @import("JS.zig");export fn step(timestamp: f32) void {
JS.Console.log("timestamp: {}\n", .{timestamp});
}
```## Build
```shell
$ zig version
0.12.0-dev.2341+92211135f
``````shell
$ zig build --verbose
``````shell
$ ls zig-out/bin/*.wasm
zig-out/bin/example.wasm
```## References
* https://github.com/daneelsan/minimal-zig-wasm-canvas
* https://github.com/daneelsan/zig-wefx
* https://github.com/ziglang/zig/blob/master/lib/std/io/writer.zig
* https://github.com/hexops/mach/blob/main/src/platform/wasm.zig
* https://github.com/hexops/mach/blob/main/src/platform/mach.js