dvConfigureRuntimeLogging function
void
dvConfigureRuntimeLogging(})
Attaches the server's own log destination.
write takes a line; the server passes stdout.writeln. Container
runtimes, systemd and every hosted platform collect a process's stdout, so
writing there is what makes a log line reach the place an operator already
looks -- and one JSON object per line is what makes it queryable once it
gets there.
DARTVEL_LOG_LEVEL sets the floor. An unreadable value falls back to
info rather than throwing: a mistyped level in a deployment's
configuration must not be the reason a service will not boot.
Implementation
void dvConfigureRuntimeLogging(
Map<String, String> environment, {
required void Function(String line) write,
}) {
DVObservability.useLogging(
sinks: <DVLogSink>[DVJsonLinesSink(write)],
level: DVLogLevel.parse(environment['DARTVEL_LOG_LEVEL'] ?? 'info'),
);
DVObservability.diagnosticsEndpoints = dvDiagnosticsEnabled(environment);
final String token = (environment['DARTVEL_METRICS_TOKEN'] ?? '').trim();
DVObservability.metricsToken = token.isEmpty ? null : token;
}