Skip to content

v0.3.0

Choose a tag to compare

@vkiryakov vkiryakov released this 13 Oct 00:08
· 47 commits to dev since this release
f5b190b

Zefir 0.3.0 adds log, structured logging for services.

log

zefir-log writes one line of JSON per record on stdout, for log collectors and log stores.

  • Constant messages and typed fields, checked at compile time: a value that cannot be logged, a field without a name or a reserved name is a compile error that names the field.
  • Secrets come out as [REDACTED]: by type (confy.Secret and any type marked zefir_sensitive) and by name (password, api_key, db_password, newPassword, …).
  • Levels and scopes that change while the service runs: setLevel and setScopeLevel.
  • Sync mode, where the call writes, and queued mode, where a lock-free queue and a writer thread keep stdout off the request path; flush and shutdown take a timeout.
  • Trace and span ids from a core.Context, the call site from @src(), and std.log routed into the same stream.
  • Subscribers for alerts, on threads of their own; interceptors that drop noise; emergency records to stderr; counters in stats().

See the log guide: a tutorial with diagrams and complete examples, from the first record to alerts in Slack.

validator

zefir-validator ships in 0.4.0. The module in this tag is an early preview: it is not covered by the compatibility promise until 0.4.0.

Other changes

  • confy: confy.Secret carries the zefir_sensitive marker, so log writes it as [REDACTED]. Its {f} now prints [REDACTED]; it printed [redacted] before.
  • core: core.isSensitive(T) tells whether a type carries the marker, plus the fixes from the core review.
  • CI: the tests also run under ThreadSanitizer on Linux and macOS, and both runs must pass for every pull request.

rpc and orm are still placeholders without an API.

Requirements

Zig 0.17.0.

Installation

zig fetch --save git+https://github.com/vkiryakov/zefir#v0.3.0
const zefir = b.dependency("zefir", .{ .target = target, .optimize = optimize });
// in your module's .imports:
.{ .name = "log", .module = zefir.module("zefir-log") },

Until 1.0, breaking changes may happen in any minor release.