Event ‣ log - chung-leong/zigar GitHub Wiki

Occurs when data gets written to stdout or stderr.

Usage

const std = @import("std");

pub fn hello() void {
    std.debug.print("Hello world\n", .{});
}
import { __zigar, hello } from './event-log-example-1.zig';
const { on } = __zigar;

on('log', (evt) => {
  console.log(evt);
  return true;
});
hello();
{ source: 'stderr', message: 'Hello world' }

Event fields:

  • source: string
    Name of The stream to which data was sent. Either "stdout" or "stderr".
  • message: string
    Text that was sent.

Return value:

boolean|undefined
true if the message was processed, false if it was ignored. undefined means the listener declined to handle the event, allowing the default action of calling console.log() to occur.


Events