Log method

void Log({
  1. required String className,
  2. required String methodName,
  3. required String text,
  4. required String type,
  5. required String logName,
})

Implementation

void Log({
  required String className,
  required String methodName,
  required String text,
  required String type,
  required String logName,
}) async {
  if (enabledLogsList != null &&
      enabledLogsList.contains('$BASE_LOG_NAME$logName')) {
    try {
      if (_packageInfo == null) setPackageInfo();
      final info = NetworkInfo();
      var wifiIP = await info.getWifiIP();
      var log = LogModel(
        id: Uuid().v4(),
        createdAt: DateTime.now(),
        fromDevice: 'mobile',
        message: 'logName: $BASE_LOG_NAME$logName, methodName: $methodName, ' +
            text +
            ', createdAt: ${DateTime.now().dateToString()}, App version: ${packageInfo!.version} + ${packageInfo!.buildNumber}',
        ip: wifiIP,
        type: type,
        title: className,
      );
      createRemoteLog(log.toJson());
    } catch (e) {
      final info = NetworkInfo();
      var wifiIP = await info.getWifiIP();
      var log = LogModel(
        id: Uuid().v4(),
        createdAt: DateTime.now(),
        fromDevice: 'mobile',
        message:
            'logName: $BASE_LOG_NAME$logName, methodName: Log, error: $e, createdAt: ${DateTime.now().dateToString()}, App version: ${packageInfo!.version} + ${packageInfo!.buildNumber}',
        ip: wifiIP,
        type: 'ERROR',
        title: className,
      );
      createRemoteLog(log.toJson());
      var log2 = LogModel(
        id: Uuid().v4(),
        createdAt: DateTime.now(),
        fromDevice: 'mobile',
        message:
            '[catch] logName: $BASE_LOG_NAME$logName, methodName: $methodName, ' +
                text +
                ', createdAt: ${DateTime.now().dateToString()}, App version: ${packageInfo!.version} + ${packageInfo!.buildNumber}',
        ip: wifiIP,
        type: type,
        title: className,
      );
      createRemoteLog(log2.toJson());
    }
  }
}