Merge pull request #9 from wagesj45/codex/fix-cache-logging-to-print-only-new-key/value-pair
Fix cache logging
This commit is contained in:
commit
4610e10433
1 changed files with 5 additions and 3 deletions
|
@ -67,12 +67,14 @@ class CustomerTermBase {
|
|||
}
|
||||
}
|
||||
|
||||
_saveCache() {
|
||||
_saveCache(updatedKey, updatedValue) {
|
||||
console.log(`[ai-filter][ExpressionSearchFilter] Saving cache to ${this._cacheFile.path}`);
|
||||
if (typeof updatedKey !== "undefined") {
|
||||
console.log(`[ai-filter][ExpressionSearchFilter] ⮡ Persisting entry '${updatedKey}' → ${updatedValue}`);
|
||||
}
|
||||
try {
|
||||
let obj = Object.fromEntries(this.cache);
|
||||
let data = JSON.stringify(obj);
|
||||
console.log(`[ai-filter][ExpressionSearchFilter] Cache data to write: ${data}`);
|
||||
let stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
|
||||
stream.init(this._cacheFile,
|
||||
FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE,
|
||||
|
@ -254,7 +256,7 @@ class ClassificationTerm extends CustomerTermBase {
|
|||
|
||||
console.log(`[ai-filter][ExpressionSearchFilter] Caching entry '${key}' → ${matched}`);
|
||||
this.cache.set(key, matched);
|
||||
this._saveCache();
|
||||
this._saveCache(key, matched);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`[ai-filter][ExpressionSearchFilter] HTTP request failed:`, e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue