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: 3 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 (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-09T16:42:25.000Z (4 months ago)
- Last Synced: 2025-03-25T17:46:57.919Z (3 months ago)
- Topics: javascript, wasm, zig
- Language: Zig
- Homepage:
- Size: 295 KB
- Stars: 18
- 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/

## 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.14.0
``````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