serverpod_logger_plus 0.5.2
serverpod_logger_plus: ^0.5.2 copied to clipboard
Plug-and-play structured logging for Serverpod: dual-routes each log to Serverpod Insights and structured JSON on stdout for GCP, Datadog, Elastic, and more.
0.5.2 #
- The configured
redactornow also runs over a logged exception's text. It is called with the key'exception'(exported asexceptionRedactionKey) andexception.toString(), so a Postgres error such asKey (email)=(x@y.com) already existscan be scrubbed before it reaches Serverpod's session-log table or yourLogWriter. When the redactor changes the text, both sinks receive aRedactedExceptionwhosetoString()is the new text and whoseruntimeTypeis the original exception's type. Returningnulldrops the exception. Without aredactorthe exception is passed through untouched and is not stringified.redactKeysdoes not apply to exception text, and stack traces are not scanned.
0.5.1 #
- Supports Serverpod 4.0.x as well as 3.4.x: the
serverpodconstraint is now>=3.4.0 <5.0.0. No library changes were needed; theSession,LogLeveland request-header APIs this package uses are unchanged in Serverpod 4.
0.5.0 #
- New
redactKeys,redactorandredactionPlaceholderoptions onServerpodLoggerPlus.configure. Redaction is applied ahead of both sinks, so a redacted value reaches neither yourLogWriternor Serverpod's session-log table. Key matching is case-insensitive and applies at any nesting depth. It does not scan the message string, an exception'stoString(), or the stack trace. - The string sent to
Session.lognow runs throughtoJsonSafe, matching the structured writers: aDateTime,UuidValueor generated model is no longertoString()-dumped into the database, and a nested map reads as JSON. Values containing the format's separators are quoted. - Flattened values are capped at
flattenValueMaxLength(default 1024, configurable), and the whole line is capped too. TheLogWriterstill receives untruncated data. toJsonSafenow stops at a maximum nesting depth, so a cyclic payload no longer overflows the stack.- New
session.runWithLogger(body, labels:, payload:), a scoped alternative tobindLoggerthat restores the previous logger when the block ends. - New exported
logSeverityRank.minimumLevelfiltering no longer depends on the declaration order of Serverpod'sLogLevelenum. - README: new Where your log data goes section, documenting that
payloadandlabelsare persisted on every call regardless of writer, and thatminimumLevelgates only the writer.
0.4.1 #
- Documentation only: rewrote
README.md. No library changes.
0.4.0 #
- New
session.bindLogger(labels:, payload:)that enrichessession.loggerin place, so every latersession.loggercall on that session carries the bound context without threading a logger through your call stack. - Automatic request logging: pass
logRequests: truetoServerpodLoggerPlus.configure(or callsession.logger.logRequestOnClose()per request) to emit one structuredRequest completedrecord (endpoint, method, duration) to yourLogWriterwhen a session closes. - Distributed trace context: pass
bindTraceContext: trueandsession.loggerreads the incoming request's trace headers and bindstraceId/spanIdon every log call. Recognizes W3Ctraceparent, GCPX-Cloud-Trace-Context, AWSX-Amzn-Trace-Id, and Datadogx-datadog-trace-id/x-datadog-parent-id. ExposesextractTraceContext(session)and atraceContextExtractoroverride for proprietary headers. - Each writer now maps bound trace context into its provider's reserved trace
field (OTel native
traceId/spanId, ECS and New Relictrace.id/span.id, Datadogdd.trace_id/dd.span_id, GCPlogging.googleapis.com/trace).GcpJsonLogWritergains aprojectIdargument to format the reserved trace resource name for automatic log-to-trace linking. - Flushing for async writers: implement the new
FlushableLogWriterto drain in-flight work, and callServerpodLoggerPlus.flush()from your shutdown path beforepod.shutdown().MultiLogWriterfansflush()out to flushable children. - Breaking:
LogWriter.writegained optionaltraceId/spanIdnamed parameters. Custom writers that useimplements LogWritermust add them to theirwritesignature.
0.3.3 #
- Fix the broken CI badge in
README.mdon pub.dev (point it at the renamedtest.ymlworkflow).
0.3.2 #
- Align repository URLs in
pubspec.yaml,README.md, andCONTRIBUTING.mdwith the canonicalIanHeinrichGitHub owner casing.
0.3.1 #
- Add an
example/demonstrating every built-in writer plus thesession.loggerserver wiring. - Document all writer constructors.
- Shorten the pubspec
descriptionto pub.dev's recommended length.
0.3.0 #
- New
MultiLogWriterthat fans a single log call out to several writers, so you can keep a built-in structured-JSON writer and run extra work on top (e.g. an async network push) instead of having to replace the output entirely.
0.2.0 #
- New writers:
ElasticEcsLogWriter(Elastic Common Schema),NewRelicJsonLogWriter(New Relic Logs),SplunkJsonLogWriter(Splunk), andOtelJsonLogWriter(OpenTelemetry Logs / OTLP-JSON). - Breaking: replaced
CloudWatchJsonLogWriterwith the provider-neutralGenericJsonLogWriter, which emits the same flat JSON and now documents the full set of targets it fits (AWS CloudWatch, Azure Monitor / Container Insights, and any agent that indexes arbitrary stdout JSON). SwapCloudWatchJsonLogWriter()forGenericJsonLogWriter().
0.1.0 #
- Initial release.
LoggerPluscore Y-Splitter engine: dual-routes every log call toSession.log(Serverpod Insights) and a pluggableLogWriter(structured JSON / console output).- Zero-boilerplate
session.loggerextension getter, memoized per session, auto-selectingConsoleLogWriterin development and the configured production writer otherwise. - Built-in writers:
GcpJsonLogWriter,CloudWatchJsonLogWriter,DatadogJsonLogWriter,AxiomLogWriter,ConsoleLogWriter. ServerpodLoggerPlus.configurefor global production writer configuration.