LCOV - code coverage report
Current view: top level - src/trace - span_logger.dart (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 8 8
Test Date: 2025-11-15 13:23:01 Functions: - 0 0

            Line data    Source code
       1              : // Licensed under the Apache License, Version 2.0
       2              : // Copyright 2025, Michael Bushe, All rights reserved.
       3              : 
       4              : import '../../dartastic_opentelemetry.dart' show Span, OTelLog;
       5              : 
       6              : /// Logs a single span with an optional message.
       7              : ///
       8              : /// This utility function logs span information for debugging purposes.
       9              : /// It includes a timestamp and formats the span information in a consistent way.
      10              : ///
      11              : /// Note: Per [OTEP 0265](https://opentelemetry.io/docs/specs/semconv/general/events/),
      12              : /// span events are being deprecated and will be replaced by the Logging API in future versions.
      13              : ///
      14              : /// @param span The span to log
      15              : /// @param message Optional message to include with the span log
      16            1 : void logSpan(Span span, [String? message]) {
      17            1 :   if (OTelLog.logFunction != null) {
      18            2 :     final timestamp = DateTime.now().toIso8601String();
      19              :     final String msg = message ?? '';
      20            3 :     OTelLog.logFunction!('[$timestamp] [message] $msg [span] $span');
      21              :   }
      22              : }
      23              : 
      24              : /// Logs multiple spans with an optional message.
      25              : ///
      26              : /// This utility function logs information about multiple spans for debugging purposes.
      27              : /// It includes a timestamp and formats the spans information in a consistent way.
      28              : ///
      29              : /// Note: Per [OTEP 0265](https://opentelemetry.io/docs/specs/semconv/general/events/),
      30              : /// span events are being deprecated and will be replaced by the Logging API in future versions.
      31              : ///
      32              : /// @param spans The list of spans to log
      33              : /// @param message Optional message to include with the spans log
      34           17 : void logSpans(List<Span> spans, [String? message]) {
      35           17 :   if (OTelLog.isLogSpans()) {
      36           34 :     final timestamp = DateTime.now().toIso8601String();
      37              :     final String msg = message ?? '';
      38           34 :     OTelLog.spanLogFunction!('[$timestamp] [message] $msg [spans] $spans');
      39              :   }
      40              : }
        

Generated by: LCOV version 2.0-1