swiftPrint function

void swiftPrint(
  1. Object? object, {
  2. StackTrace? stackTrace,
})

Custom print function that captures logs

This function should be used instead of print() to ensure all logs are captured. When LogInterceptor is enabled, this will both print to console AND capture the log.

Example:

swiftPrint('Hello World'); // This will be captured

Implementation

void swiftPrint(Object? object, {StackTrace? stackTrace}) {
  // Call original print to ensure it appears in console
  print(object);

  // Capture log if interceptor is enabled
  if (LogInterceptor.isEnabled) {
    LogInterceptor.captureLog(
      message: object?.toString() ?? '',
      type: LogType.print,
      data: object,
      stackTrace: stackTrace,
    );
  }
}