Remove all log statements
Because THEY were causing the lag?????????
This commit is contained in:
130
lib/mod.dart
130
lib/mod.dart
@@ -59,28 +59,28 @@ class Mod {
|
||||
}
|
||||
|
||||
static Mod fromDirectory(String path, {bool skipFileCount = false}) {
|
||||
final logger = Logger.instance;
|
||||
final stopwatch = Stopwatch()..start();
|
||||
// final logger = Logger.instance;
|
||||
// final stopwatch = Stopwatch()..start();
|
||||
|
||||
logger.info('Attempting to load mod from directory: $path');
|
||||
// logger.info('Attempting to load mod from directory: $path');
|
||||
final aboutFile = File('$path/About/About.xml');
|
||||
if (!aboutFile.existsSync()) {
|
||||
logger.error('About.xml file does not exist in $aboutFile');
|
||||
// logger.error('About.xml file does not exist in $aboutFile');
|
||||
throw Exception('About.xml file does not exist in $aboutFile');
|
||||
}
|
||||
|
||||
logger.info('Parsing About.xml file...');
|
||||
// logger.info('Parsing About.xml file...');
|
||||
final aboutXml = XmlDocument.parse(aboutFile.readAsStringSync());
|
||||
final xmlTime = stopwatch.elapsedMilliseconds;
|
||||
// final xmlTime = stopwatch.elapsedMilliseconds;
|
||||
|
||||
late final XmlElement metadata;
|
||||
try {
|
||||
metadata = findCaseInsensitiveDoc(aboutXml, 'ModMetaData');
|
||||
logger.info('Successfully found ModMetaData in About.xml');
|
||||
// logger.info('Successfully found ModMetaData in About.xml');
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Error: ModMetaData element is missing in About.xml ($aboutFile). Original error: $e',
|
||||
);
|
||||
// logger.error(
|
||||
// 'Error: ModMetaData element is missing in About.xml ($aboutFile). Original error: $e',
|
||||
// );
|
||||
throw Exception(
|
||||
'Error: ModMetaData element is missing in About.xml ($aboutFile). Original error: $e',
|
||||
);
|
||||
@@ -89,11 +89,11 @@ class Mod {
|
||||
late final String name;
|
||||
try {
|
||||
name = metadata.findElements('name').first.innerText;
|
||||
logger.info('Mod name found: $name');
|
||||
// logger.info('Mod name found: $name');
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Error: name element is missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
);
|
||||
// logger.error(
|
||||
// 'Error: name element is missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
// );
|
||||
throw Exception(
|
||||
'Error: name element is missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
);
|
||||
@@ -102,11 +102,11 @@ class Mod {
|
||||
late final String id;
|
||||
try {
|
||||
id = metadata.findElements('packageId').first.innerText.toLowerCase();
|
||||
logger.info('Mod ID found: $id');
|
||||
// logger.info('Mod ID found: $id');
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Error: packageId element is missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
);
|
||||
// logger.error(
|
||||
// 'Error: packageId element is missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
// );
|
||||
throw Exception(
|
||||
'Error: packageId element is missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
);
|
||||
@@ -121,11 +121,11 @@ class Mod {
|
||||
.findElements('li')
|
||||
.map((e) => e.innerText)
|
||||
.toList();
|
||||
logger.info('Supported versions found: ${versions.join(", ")}');
|
||||
// logger.info('Supported versions found: ${versions.join(", ")}');
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Error: supportedVersions or li elements are missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
);
|
||||
// logger.error(
|
||||
// 'Error: supportedVersions or li elements are missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
// );
|
||||
throw Exception(
|
||||
'Error: supportedVersions or li elements are missing in ModMetaData ($aboutFile). Original error: $e',
|
||||
);
|
||||
@@ -134,11 +134,11 @@ class Mod {
|
||||
String description = '';
|
||||
try {
|
||||
description = metadata.findElements('description').first.innerText;
|
||||
logger.info('Mod description found: $description');
|
||||
// logger.info('Mod description found: $description');
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
'Description element is missing in ModMetaData ($aboutFile).',
|
||||
);
|
||||
// logger.warning(
|
||||
// 'Description element is missing in ModMetaData ($aboutFile).',
|
||||
// );
|
||||
}
|
||||
|
||||
List<String> dependencies = [];
|
||||
@@ -156,11 +156,11 @@ class Mod {
|
||||
e.findElements("packageId").first.innerText.toLowerCase(),
|
||||
)
|
||||
.toList();
|
||||
logger.info('Dependencies found: ${dependencies.join(", ")}');
|
||||
// logger.info('Dependencies found: ${dependencies.join(", ")}');
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
'Dependencies element is missing in ModMetaData ($aboutFile).',
|
||||
);
|
||||
// logger.warning(
|
||||
// 'Dependencies element is missing in ModMetaData ($aboutFile).',
|
||||
// );
|
||||
}
|
||||
|
||||
List<String> loadAfter = [];
|
||||
@@ -172,13 +172,13 @@ class Mod {
|
||||
.findElements('li')
|
||||
.map((e) => e.innerText.toLowerCase())
|
||||
.toList();
|
||||
logger.info(
|
||||
'Load after dependencies found: ${loadAfter.isNotEmpty ? loadAfter.join(", ") : "none"}',
|
||||
);
|
||||
// logger.info(
|
||||
// 'Load after dependencies found: ${loadAfter.isNotEmpty ? loadAfter.join(", ") : "none"}',
|
||||
// );
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
'Load after element is missing or empty in ModMetaData ($aboutFile). Original error: $e',
|
||||
);
|
||||
// logger.warning(
|
||||
// 'Load after element is missing or empty in ModMetaData ($aboutFile). Original error: $e',
|
||||
// );
|
||||
}
|
||||
List<String> loadAfterForce = [];
|
||||
try {
|
||||
@@ -189,13 +189,13 @@ class Mod {
|
||||
.findElements('li')
|
||||
.map((e) => e.innerText.toLowerCase())
|
||||
.toList();
|
||||
logger.info(
|
||||
'Force load after dependencies found: ${loadAfterForce.isNotEmpty ? loadAfterForce.join(", ") : "none"}',
|
||||
);
|
||||
// logger.info(
|
||||
// 'Force load after dependencies found: ${loadAfterForce.isNotEmpty ? loadAfterForce.join(", ") : "none"}',
|
||||
// );
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
'Force load after element is missing or empty in ModMetaData ($aboutFile). Original error: $e',
|
||||
);
|
||||
// logger.warning(
|
||||
// 'Force load after element is missing or empty in ModMetaData ($aboutFile). Original error: $e',
|
||||
// );
|
||||
}
|
||||
dependencies.addAll(loadAfterForce);
|
||||
|
||||
@@ -208,13 +208,13 @@ class Mod {
|
||||
.findElements('li')
|
||||
.map((e) => e.innerText.toLowerCase())
|
||||
.toList();
|
||||
logger.info(
|
||||
'Load before dependencies found: ${loadBefore.isNotEmpty ? loadBefore.join(", ") : "none"}',
|
||||
);
|
||||
// logger.info(
|
||||
// 'Load before dependencies found: ${loadBefore.isNotEmpty ? loadBefore.join(", ") : "none"}',
|
||||
// );
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
'Load before element is missing or empty in ModMetaData ($aboutFile). Original error: $e ',
|
||||
);
|
||||
// logger.warning(
|
||||
// 'Load before element is missing or empty in ModMetaData ($aboutFile). Original error: $e ',
|
||||
// );
|
||||
}
|
||||
|
||||
List<String> incompatibilities = [];
|
||||
@@ -226,14 +226,14 @@ class Mod {
|
||||
.findElements('li')
|
||||
.map((e) => e.innerText.toLowerCase())
|
||||
.toList();
|
||||
logger.info('Incompatibilities found: ${incompatibilities.join(", ")}');
|
||||
// logger.info('Incompatibilities found: ${incompatibilities.join(", ")}');
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
'Incompatibilities element is missing in ModMetaData ($aboutFile).',
|
||||
);
|
||||
// logger.warning(
|
||||
// 'Incompatibilities element is missing in ModMetaData ($aboutFile).',
|
||||
// );
|
||||
}
|
||||
|
||||
final metadataTime = stopwatch.elapsedMilliseconds - xmlTime;
|
||||
// final metadataTime = stopwatch.elapsedMilliseconds - xmlTime;
|
||||
|
||||
int size = 0;
|
||||
if (!skipFileCount) {
|
||||
@@ -273,9 +273,9 @@ class Mod {
|
||||
: vA[1] - vB[1]; // Compare major, then minor version
|
||||
});
|
||||
latestVersionDir = versionDirs.last;
|
||||
logger.info(
|
||||
'Latest version directory found: ${latestVersionDir.path.split(Platform.pathSeparator).last}',
|
||||
);
|
||||
// logger.info(
|
||||
// 'Latest version directory found: ${latestVersionDir.path.split(Platform.pathSeparator).last}',
|
||||
// );
|
||||
}
|
||||
|
||||
// Count all files, excluding older version directories
|
||||
@@ -299,19 +299,19 @@ class Mod {
|
||||
return true;
|
||||
}).length;
|
||||
|
||||
logger.info(
|
||||
'File count in mod directory (with only latest version): $size',
|
||||
);
|
||||
// logger.info(
|
||||
// 'File count in mod directory (with only latest version): $size',
|
||||
// );
|
||||
}
|
||||
|
||||
final fileCountTime =
|
||||
stopwatch.elapsedMilliseconds - metadataTime - xmlTime;
|
||||
final totalTime = stopwatch.elapsedMilliseconds;
|
||||
// final fileCountTime =
|
||||
// stopwatch.elapsedMilliseconds - metadataTime - xmlTime;
|
||||
// final totalTime = stopwatch.elapsedMilliseconds;
|
||||
|
||||
// Log detailed timing information
|
||||
logger.info(
|
||||
'Mod $name timing: XML=${xmlTime}ms, Metadata=${metadataTime}ms, FileCount=${fileCountTime}ms, Total=${totalTime}ms',
|
||||
);
|
||||
// logger.info(
|
||||
// 'Mod $name timing: XML=${xmlTime}ms, Metadata=${metadataTime}ms, FileCount=${fileCountTime}ms, Total=${totalTime}ms',
|
||||
// );
|
||||
|
||||
return Mod(
|
||||
name: name,
|
||||
|
Reference in New Issue
Block a user