Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@polyglot-logger/node

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/node
import { 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.

Config file (optional)

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.log
new Logger({ service: "checkout-api" }); // sinks from YAML

Full schema: configuration · zero-config.

Levels, fields, lifecycle

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: tracefatal (fatal does not exit the process).
  • Prefer with(fields) for per-request context; avoid sharing setFields across concurrent requests.
  • One instance is fine for concurrent log / flush / stats / setFields / reloadConfig. Call close() from a single owner.

Native library

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.dylib

Intel Macs: arm64 is what ships today; set POLYGLOT_LOGGER_LIB for amd64 until CI covers it.

From source

git clone --recurse-submodules https://github.com/kishankumarhs/Polyglot.git
cd Polyglot && make build-native
cd bindings/node && npm install && npm run build

Docs

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages