Node / TypeScript bindings for Polyglot — a shared Go logging core with a C ABI. Same polyglot.yaml, JSON shape, and sinks as the Python and .NET packages. Native libs ship in the npm package (Linux, Windows, macOS arm64); no Go/CGO required.
Current line: 0.3.x (npm view @polyglot-logger/node version).
npm install @polyglot-logger/nodeimport { Logger } from "@polyglot-logger/node";
const log = new Logger({ service: "api", stdout: true });
log.info("hello", { user_id: 1 });
log.flush();
log.close();Side-by-side with Python/.NET: sdk.md.
Constructors load polyglot.yaml via POLYGLOT_CONFIG → cwd → parents (stop at .git). Options override file keys.
# polyglot.yaml (repo root)
service: checkout-api
environment: prod
level: info
stdout: true
file:
enabled: true
path: /var/log/checkout.lognew Logger({ service: "checkout-api" }); // sinks from YAMLFull schema: configuration · zero-config.
import { Logger, Level } from "@polyglot-logger/node";
const log = new Logger({
service: "checkout-api",
environment: "prod",
level: "info",
stdout: true,
});
log.setFields({ region: "us-east" });
const req = log.with({ request_id: "r1" });
req.info("checkout started", { cartId: "c-1" });
req.logSimple(Level.ERROR, "payment declined");
req.close();
log.flush();
log.close();- Levels:
trace…fatal(fataldoes not exit the process). - Prefer
with(fields)for per-request context; avoid sharingsetFieldsacross concurrent requests. - One instance is fine for concurrent
log/flush/stats/setFields/reloadConfig. Callclose()from a single owner.
Published packages include platform natives under bin/ / native/. For a local monorepo build, point at the shared lib:
export POLYGLOT_LOGGER_LIB=$PWD/dist/liblogger.so # logger.dll / liblogger.dylibIntel Macs: arm64 is what ships today; set POLYGLOT_LOGGER_LIB for amd64 until CI covers it.
git clone --recurse-submodules https://github.com/kishankumarhs/Polyglot.git
cd Polyglot && make build-native
cd bindings/node && npm install && npm run build- First log
- Node API
- Configuration
- Sinks & Loki
- Migrate from Pino
- Compatibility
- Benchmarks / methodology
Polyglot is for multi-language stacks that want one ops model — not a drop-in “faster than Pino” replacement. Node pays an FFI tax (~1.6 µs per call in recent local runs); see the bench README for numbers.
Repos: polyglot-node · core: Polyglot
MIT