logger_builder 0.5.0
logger_builder: ^0.5.0 copied to clipboard
A toolkit for creating your own customizable and hierarchical loggers in Dart.
0.5.0 #
- Pre-publication log processing: the new
LogTransformertypedef (Log? Function(Log)), theCustomLogger.transformerproperty applied to every log right before publishing (inherited by subloggers likelevel/publisher, same link/unlink/relinksemantics), and theTransformPublisherwrapper for per-destination transformation. Returningnulldrops the log. Fail-closed: a throwing transformer drops the log and reports the error toonError(TransformPublisher) or the current zone. - [breaking changes]
CustomLevelLoggergains the protectedpublishLog:processLogimplementations must call it instead ofpublisher.publish(...), otherwiseCustomLogger.transformeris ignored. - The new protected
CustomLog.copycopies level fields and the zone from an existing log and assignserror/stackTraceverbatim — the building block forcopyWithin subclasses (a copy keeps the log's identity: no new number or time should be minted).
0.4.0 #
- [breaking changes] Publisher lifecycle interfaces:
HasFlushis renamed toFlushable(HasFlushremains as a deprecated alias), and the newClosableinterface exposesclose(). All async publishers implement both;MultiPublisher.close()closes everyClosablepublisher in its list. - [breaking changes]
MultiPublisher.flushwithonErrorset now routes each publisher's error to the callback and completes normally; withoutonErrorthe previous behavior (ParallelWaitError) is preserved.closeerrors are routed the same way. - [breaking changes]
MultiPublishercopies the publisher list at construction; mutating the original list no longer affects the publisher. - [breaking changes]
CustomLevelLoggeris now anabstract base class: it can be extended, but no longer implemented outside the package. - New hierarchy management API:
CustomLogger.levelslists the registered level values (a live view);CustomLogger.relink()re-attaches an unlinked sublogger to its parent (re-inheriting the level and publishers). The unlink idiom (child.level = child.level) is now documented. Note: a subclass that already declares a compatible member namedlevelsorrelinkwill silently override the new API — rename such members. MultiPublishernow has a closed state:publishafterclose()throws aStateError, repeatedclose()calls return the same future, and a newisClosedgetter reports the state. A throwingonErrorcallback no longer escapes to the logging call site or replaces the original error inflush/close— the secondary error is reported to the current zone.- The
public_member_api_docslint is enabled; every public member is documented.
0.3.3 #
AsyncPublisherWithBuffer/AsyncPublisherWithBufferAndParam:flush()no longer hangs on an idle queue — it completes immediately. Flush has drain semantics: it also waits for logs published after the call, until the buffer becomes empty.- All async publishers: a new optional
onErrorcallback receives errors thrown by the handler; without it, the error is reported to the current zone (same asMultiPublisher). A throwing handler no longer stalls the queue, loses the retry buffer, or leavesflush()hanging. - All async publishers: a new
isClosedgetter.publishafterclose()now always throws aStateError(buffered publishers used to silently accept logs into a dead buffer);flush()afterclose()completes immediately instead of resurrecting the publisher; repeatedclose()calls are no-ops returning the same future. AsyncPublisher/AsyncPublisherWithParam: concurrentflush()calls are now serialized — an overlapping flush no longer hangs forever and no longer loses queued logs.- Buffered publishers:
close()now drains the queue completely — logs published while a batch was in flight are processed instead of being silently dropped. Entries returned to the retry buffer after closing are dropped by design (documented). - All async publishers: an
onErrorcallback that itself throws can no longer stall the queue; the secondary error is reported to the current zone and processing continues. AsyncFormatterfamily: whenOutisObject?/dynamic, an asynchronousformatresult is now awaited instead of being passed tooutputas an unresolvedFuture.AsyncFormatterWithBuffer/AsyncFormatterWithBufferAndParam: the batch passed tooutputnow reflects retry-buffer additions made during an asynchronousformat.TypedLazy(LazyString,LazyStringOrNull): readingresolvedaftervaluenow returns the converted value instead of leaking an internal sentinel object.LazyString.resolved: the defaultfallbackValueis now'null', same as the main constructor.CustomLevelLogger: an emptynamenow throws anArgumentErrorin all build modes (previously an assert, and aRangeErrorin release); the defaultshortNameis the first code point of the name, correct for non-BMP characters.- Hierarchy: setting a per-level publisher on a logger no longer throws mid-propagation when a sublogger did not register that level.
- Hierarchy: sublogger bookkeeping no longer uses a
Finalizerthat kept the parent logger strongly reachable through its live subloggers; dead weak references are pruned automatically during traversals. - Internal stream subscriptions are now stored and cancelled on
close(). - Docs: dartdoc for
HasFlush, async publisher members, theLazyfamily,Levelsconstants andCustomLog.zone. - Tests: the async publisher family, the
Lazyfamily, and level/hierarchy edge cases are now covered (63 new tests).
0.3.2 #
MultiPublisher: an exception thrown by one publisher no longer interrupts publishing to the remaining publishers and no longer propagates to the logging call site. The newonErrorcallback receives the failing publisher along with the error; without it, the error is reported to the current zone as an uncaught asynchronous error.MultiPublisher.flush: a synchronous throw from one publisher'sflushno longer prevents flushing the others.
0.3.0-0.3.1 #
- [breaking changes] Refactor a builder and a printer to one publisher.
- Add the async publisher family:
AsyncPublisher,AsyncPublisherWithParam,AsyncPublisherWithBuffer,AsyncPublisherWithBufferAndParamandMultiPublisher(recorded retroactively). - Upgrade ansi_escape_codes to 3.0.2 for examples.
0.2.0 #
- [breaking changes] Rename
LazyStringtoLazyStringOrNullandLazyNonNullableStringtoLazyString. - Refactor
hierarchical_logger.dartexample to useLazyStringfor path.
0.1.3-0.1.4 #
- Fix bug with builder and printer inheritance in subloggers.
0.1.2 #
- Add a CI badge to README.
- Remove vm_service from example.
- Add GitHub Actions for CI.
- Downgrade Dart SDK constraint to 3.2.0.
- Downgrade meta to 1.16.0.
0.1.0-0.1.1 #
- Initial version.