Commit 63162cbd
63162cbd10e2Merged
JVQ <[email protected]> · 4 months ago · 7 files · +1 added · ~6 modified
Description
feat: child loggers, structured meta, Error serialization, timers, TTY-aware color
- Add logger.child(meta) for context-binding child loggers; merges static and dynamic meta from parent, supports arbitrary nesting
- Widen meta type from Record<string,string> to Record<string,unknown> so numbers, booleans, and objects pass through to JSON/logfmt sinks
- Serialize Error arguments to { name, message, stack } on HellogMessage.error for structured sinks; human content unchanged via util.format
- Add time(label)/timeEnd(label) duration timers using process.hrtime.bigint() with durationMs in meta; no memory leak on unknown labels
- Add isLevelEnabled(level) guard for expensive argument construction
- Make HellogColorizeDefaultPlugin TTY-aware: auto-detects process.stdout.isTTY, NO_COLOR, FORCE_COLOR; accepts { enabled? } override
- Convert DefaultPlugins static array to per-instance factory to prevent cross-logger state bleed as plugins gain state
- New lib/errors.ts with SerializedError interface and serializeError() util
- 32 tests, 97% coverage (up from 17 tests, 88% coverage)
- Zero new runtime dependencies; full backward compatibility
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- 63162cbd10e2
- Parent
- c088f6c4b226
lib/errors.tsaddedView file
1+
export interface SerializedError {2+
name: string;3+
message: string;4+
stack?: string | undefined;5+
}6+
7+
export function serializeError(err: unknown): SerializedError | undefined {8+
if (!(err instanceof Error)) return undefined;9+
return {10+
name: err.name,11+
message: err.message,12+
stack: err.stack,13+
};14+
}lib/hellog.spec.tsmodifiedView file
Loading diff…
lib/hellog.tsmodifiedView file
Loading diff…
lib/index.tsmodifiedView file
Loading diff…
lib/messages.tsmodifiedView file
Loading diff…
lib/plugins.spec.tsmodifiedView file
Loading diff…
lib/plugins.tsmodifiedView file
Loading diff…