matchesDebugLevels method

bool matchesDebugLevels({
  1. FetchTrayLogLevel logType = FetchTrayLogLevel.info,
  2. FetchTrayDebugLevel requestDebugLevel = FetchTrayDebugLevel.everything,
})

Compares the logType to the requestDebugLevel to find out whether a debug Info should be shown for this combination or not.

The result will be a boolean telling us whether we should log something.

Implementation

bool matchesDebugLevels({
  FetchTrayLogLevel logType = FetchTrayLogLevel.info,
  FetchTrayDebugLevel requestDebugLevel = FetchTrayDebugLevel.everything,
}) {
  // log level none
  if (requestDebugLevel == FetchTrayDebugLevel.none) {
    return false;
  }

  // log level errors
  if (requestDebugLevel == FetchTrayDebugLevel.onlyErrors &&
      logType == FetchTrayLogLevel.error) {
    return true;
  }

  // log level errors and warnings
  if (requestDebugLevel == FetchTrayDebugLevel.errorsAndWarnings &&
      (logType == FetchTrayLogLevel.warning ||
          logType == FetchTrayLogLevel.error)) {
    return true;
  }

  // log level everything
  if (requestDebugLevel == FetchTrayDebugLevel.everything) {
    return true;
  }

  // otherwise always return false
  return false;
}