@arindam-stack/logify
v0.1.0
Published
Smart, configurable logger for React apps with levels, env defaults, and redaction.
Downloads
29
Maintainers
Readme
@arindam-stack/logify
Smart, configurable logging for React applications with log levels, env-aware defaults, and optional redaction.
Install
npm install @arindam-stack/logifyUsage
import createLogger from "@arindam-stack/logify";
const log = createLogger("Auth", { withTimestamp: true, redactKeys: ["token"] });
log.info("User signed in", { userId: "u_123", token: "secret" });
log.warn("Suspicious activity", { ip: "192.0.2.1" });
log.error("Login failed", { reason: "invalid_password" });API
createLogger(namespace?, options?)
Options:
enabled: boolean, defaulttruelevel:"silent" | "error" | "warn" | "info" | "debug"withTimestamp: adds ISO timestamp prefixredactKeys: array of keys to redact from object payloadsformatter: customize output shapesink: provide a custom console-like sinkdetectEnv: whentrue, usesNODE_ENVto choose a default level (defaultfalse)
Default level behavior when detectEnv is enabled:
NODE_ENV === "production"=>warn- otherwise =>
debug
Global Defaults
import { setLoggerDefaults } from "@arindam-stack/logify";
setLoggerDefaults({ withTimestamp: true, level: "info" });Notes
- For stable loggers, pass a stable options object (memoize in React if needed).
redactKeysperforms a shallow redaction on object payloads.
