debugLog function

void debugLog({
  1. required DebugLoggingSettings debugLoggingSettings,
  2. required String className,
  3. required String method,
  4. String? name,
  5. String? id,
  6. dynamic args,
})

Implementation

void debugLog(
    {required DebugLoggingSettings debugLoggingSettings,
    required String className,
    required String method,
    String? name,
    String? id,
    dynamic args}) {
  if (debugLoggingSettings.enabled) {
    for (var regExp in debugLoggingSettings.excludeFilter) {
      if (regExp.hasMatch(method)) return;
    }
    var maxLogMessageLength = debugLoggingSettings.maxLogMessageLength;
    String message =
        "(${Util.isWeb ? 'Web' : defaultTargetPlatform.name}) ${name ?? className}" +
            (id != null ? ' ID $id' : '') +
            ' calling "' +
            method.toString() +
            '" using ' +
            args.toString();
    if (maxLogMessageLength >= 0 && message.length > maxLogMessageLength) {
      message = message.substring(0, maxLogMessageLength) + '...';
    }
    if (!debugLoggingSettings.usePrint) {
      developer.log(message, name: className);
    } else {
      print('[${className}] $message');
    }
  }
}