Advanced Warner Usage
Learn advanced warning collection patterns, custom configurations, and integration strategies.
Multiple Warning Levels
Configure different warning levels for different message types:
ts
import { Warner } from "@briklab/lib/warner";
const warner = new Warner({
level: "full",
packageName: "DataProcessor",
protectionLevel: "boundary"
});
// Critical warnings
warner.warn({
message: "Invalid data format detected",
source: "parser",
level: "error",
hint: "Check input file format"
});
// Non-critical warnings
warner.warn({
message: "Deprecated field used",
source: "mapper",
level: "warn",
hint: "Use newField instead"
});
warner.finalize();Summary Mode for CI/CD
Optimize warning output for CI/CD pipelines:
ts
import { Warner } from "@briklab/lib/warner";
const warner = new Warner({
level: "summary", // Only shows count
packageName: "BuildProcess",
protectionLevel: "boundary"
});
// Collect many warnings
for (let i = 0; i < 10; i++) {
warner.warn({
message: `Processing warning ${i + 1}`,
source: "build"
});
}
// Finalize shows only: "BuildProcess: 10 warnings"
warner.finalize();Live Demo - Warning Management
Console
No logs yet.
Silent Mode for Testing
Collect warnings without output:
ts
import { Warner } from "@briklab/lib/warner";
const warner = new Warner({
level: "silent", // No output
packageName: "TestSuite"
});
// Collect warnings silently
warner.warn({ message: "Test warning 1" });
warner.warn({ message: "Test warning 2" });
// Check warning count programmatically
console.log("Warnings collected silently");
warner.finalize(); // Still no outputCustom Warning Organization
Organize warnings by source:
ts
import { Warner } from "@briklab/lib/warner";
const warner = new Warner({
level: "full",
packageName: "Application"
});
const sources = ["validation", "parser", "compiler", "optimizer"];
sources.forEach(source => {
warner.warn({
message: `Issue in ${source}`,
source,
hint: `Review ${source} configuration`
});
});
warner.finalize();Flushing vs Finalizing
Understand the difference:
ts
import { Warner } from "@briklab/lib/warner";
const warner = new Warner({
level: "full",
packageName: "Process"
});
// Add warnings
warner.warn({ message: "First warning" });
warner.warn({ message: "Second warning" });
// Flush: print warnings but keep collecting
warner.flush();
// Add more warnings
warner.warn({ message: "Third warning" });
// Finalize: print remaining warnings and stop
warner.finalize();Next Steps
- Getting Started: Back to basics
- Examples: Real-world scenarios