Skip to content

Getting Started with Warner ​

Warner is a structured warning collector for organizing and reporting warnings in your applications.

What is Warner? ​

Warner collects warnings and displays them based on warning levels and modes. It helps you manage diagnostics and warnings in a clean, organized way.

ts
import { Warner } from "@briklab/lib/warner";

const warner = new Warner({
  level: "summary",
  packageName: "my-app"
});

warner.warn({
  message: "Deprecated API used",
  hint: "Use newAPI() instead"
});

warner.finalize();

Basic Usage ​

Creating a Warner Instance ​

ts
import { Warner } from "@briklab/lib/warner";

const warner = new Warner({
  level: "summary",        // Display mode: 'silent', 'summary', or 'full'
  packageName: "my-app",   // Package identifier
  protectionLevel: "boundary"
});

Adding Warnings ​

ts
warner.warn({
  message: "Something needs attention",
  source: "config-loader",
  hint: "Check the documentation",
  level: "warn"
});

Finalizing ​

ts
// Print all collected warnings
warner.finalize();

// Or flush without finalizing
warner.flush();

Live Demo ​

Recommended to test it in your browser. The test here might not work properly
Console
No logs yet.

Warning Levels ​

  • "silent": Collect warnings without printing
  • "summary": Show count of warnings on finalize
  • "full": Print detailed warning information

Features ​

  • Queuing: Warnings are collected and printed together
  • Organization: Group warnings by source
  • Customizable: Control output verbosity
  • Protection Levels: Configure validation strictness

Next Steps ​

Learn more about Warner: