Still logging if disabled (#1038)

This commit is contained in:
nobody 2022-07-01 06:48:31 +02:00
parent 2715e6e810
commit 1396fd011e
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
3 changed files with 12 additions and 14 deletions

View File

@ -150,10 +150,6 @@ requestAnalyzer._matchBasePath = function (hostMappings, channelPath) {
requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channelHost, channelPath, destinationSearchString, initiator) { requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channelHost, channelPath, destinationSearchString, initiator) {
let resourcePath, versionNumber, resourcePattern, shorthandResource; let resourcePath, versionNumber, resourcePattern, shorthandResource;
storageManager.type.get(Setting.LOGGING, function (items) {
requestAnalyzer.logging = items.enableLogging;
});
resourcePath = channelPath.replace(basePath, ''); resourcePath = channelPath.replace(basePath, '');
// Evaluate first in case of version 'latest' and numerals in resource // Evaluate first in case of version 'latest' and numerals in resource
@ -170,10 +166,8 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
shorthandResource = shorthands.specialFiles(channelHost, channelPath, destinationSearchString); shorthandResource = shorthands.specialFiles(channelHost, channelPath, destinationSearchString);
if (shorthandResource['result'] !== false) { if (shorthandResource['result'] !== false) {
if (requestAnalyzer.logging) {
console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${shorthandResource.path}`); console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${shorthandResource.path}`);
log.append(initiator, channelHost + channelPath, shorthandResource.path, false); log.append(initiator, channelHost + channelPath, shorthandResource.path, false);
}
return shorthandResource; return shorthandResource;
} }
@ -214,10 +208,9 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
break; break;
} }
if (requestAnalyzer.logging) {
console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${targetPath}`); console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${targetPath}`);
log.append(initiator, channelHost + channelPath, targetPath, false); log.append(initiator, channelHost + channelPath, targetPath, false);
}
// Prepare and return a local target. // Prepare and return a local target.
return { return {
'source': channelHost, 'source': channelHost,
@ -229,7 +222,7 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
} }
} }
if (requestAnalyzer.logging && !IgnoredHost[channelHost]) { if (!IgnoredHost[channelHost]) {
console.warn(`${LogString.PREFIX} ${LogString.MISSING_RESOURCE} ${channelHost}${channelPath}`); console.warn(`${LogString.PREFIX} ${LogString.MISSING_RESOURCE} ${channelHost}${channelPath}`);
log.append(initiator, channelHost + channelPath, '-', true); log.append(initiator, channelHost + channelPath, '-', true);
} }

View File

@ -22,7 +22,11 @@
var log = {}; var log = {};
log.append = function (initiator, resource, target, highlight) { log.append = function (initiator, resource, target, highlight) {
storageManager.type.get(Setting.LOGGING, function (items) {
if (items.enableLogging) {
log.data.push({initiator, resource, target, highlight}); log.data.push({initiator, resource, target, highlight});
}
});
}; };
log.data = []; log.data = [];

View File

@ -69,6 +69,7 @@
<p>Fixed</p> <p>Fixed</p>
<ul> <ul>
<li>Badge color for missing resources (<a href="https://codeberg.org/nobody/LocalCDN/issues/1031">#1031</a>)</li> <li>Badge color for missing resources (<a href="https://codeberg.org/nobody/LocalCDN/issues/1031">#1031</a>)</li>
<li>Still logging if disabled (<a href="https://codeberg.org/nobody/LocalCDN/issues/1038">#1038</a>)</li>
</ul> </ul>
</div> </div>
<div id="generator-section"> <div id="generator-section">