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) {
let resourcePath, versionNumber, resourcePattern, shorthandResource;
storageManager.type.get(Setting.LOGGING, function (items) {
requestAnalyzer.logging = items.enableLogging;
});
resourcePath = channelPath.replace(basePath, '');
// 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);
if (shorthandResource['result'] !== false) {
if (requestAnalyzer.logging) {
console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${shorthandResource.path}`);
log.append(initiator, channelHost + channelPath, shorthandResource.path, false);
}
return shorthandResource;
}
@ -214,10 +208,9 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
break;
}
if (requestAnalyzer.logging) {
console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${targetPath}`);
log.append(initiator, channelHost + channelPath, targetPath, false);
}
// Prepare and return a local target.
return {
'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}`);
log.append(initiator, channelHost + channelPath, '-', true);
}

View File

@ -22,7 +22,11 @@
var log = {};
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 = [];

View File

@ -69,6 +69,7 @@
<p>Fixed</p>
<ul>
<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>
</div>
<div id="generator-section">