Warner
Warning collector for BrikLab modules with Protection Levels.
Diagram
Constructor
ts
new Warner(options?: WarnerOptions)Properties
| Property | Type | Description |
|---|---|---|
warnings | Warning[] | Collected warnings. |
Methods
.setLevel(level: WarningLevel)
Sets the warning output level.
| Argument | Type | Description |
|---|---|---|
level | WarningLevel | Output level. |
.setProtectionLevel(level: ProtectionLevel)
Sets the protection level.
| Argument | Type | Description |
|---|---|---|
level | ProtectionLevel | Validation strictness. |
.getProtectionLevel()
Returns the current ProtectionLevel.
.setPackageName(name: string)
Sets the package name used in warning metadata.
| Argument | Type | Description |
|---|---|---|
name | string | Package name to attach to warnings. |
.clear()
Clears all collected warnings.
.count()
Returns the number of collected warnings.
.warn(warning: Warning)
Adds a warning and optionally emits it immediately.
| Argument | Type | Description |
|---|---|---|
warning | Warning | Warning payload. |
.finalize()
Finalizes warnings and logs a summary if configured.
.flush()
Alias for finalize().
References
Example
ts
const warner = new Warner({ level: "summary", protectionLevel: "boundary", packageName: "MyPackage" });
warner.warn({ message: "This is a warning", code: "WARN001", metadata: { detail: "Additional info" } });
warner.finalize();