-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added verbose messages for onFile / offFile
- Loading branch information
Showing
1 changed file
with
11 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1610,6 +1610,8 @@ function sandBox(script, name, verbose, debug, context) { | |
|
||
sandbox.__engine.__subscriptionsFile += 1; | ||
|
||
sandbox.verbose && sandbox.log(`onFile(id=${id}, fileNamePattern=${fileNamePattern}) - fileSubscriptions=${sandbox.__engine.__subscriptionsFile}`, 'info'); | ||
|
||
if (sandbox.__engine.__subscriptionsFile % adapter.config.maxTriggersPerScript === 0) { | ||
sandbox.log(`More than ${sandbox.__engine.__subscriptionsFile} file subscriptions registered. Check your script!`, 'warn'); | ||
} | ||
|
@@ -1659,10 +1661,12 @@ function sandBox(script, name, verbose, debug, context) { | |
}, | ||
offFile: function (idOrObject, fileNamePattern) { | ||
if (!adapter.unsubscribeForeignFiles) { | ||
sandbox.log('onFile: your js-controller does not support yet offFile unsubscribes. Please update to [email protected] or newer', 'warn'); | ||
sandbox.log('offFile: your js-controller does not support yet file unsubscribes. Please update to [email protected] or newer', 'warn'); | ||
return; | ||
} | ||
|
||
sandbox.verbose && sandbox.log(`offFile(idOrObject=${JSON.stringify(idOrObject)}, fileNamePattern=${fileNamePattern}) - fileSubscriptions=${sandbox.__engine.__subscriptionsFile}`, 'info'); | ||
|
||
if (idOrObject && typeof idOrObject === 'object') { | ||
if (Array.isArray(idOrObject)) { | ||
const result = []; | ||
|
@@ -1674,6 +1678,9 @@ function sandBox(script, name, verbose, debug, context) { | |
for (let i = context.subscriptionsFile.length - 1; i >= 0; i--) { | ||
if (context.subscriptionsFile[i] === idOrObject) { | ||
unsubscribeFile(script, context.subscriptionsFile[i].id, context.subscriptionsFile[i].fileNamePattern); | ||
|
||
sandbox.verbose && sandbox.log(`offFile(type=object, fileNamePattern=${fileNamePattern}, removing id=${context.subscriptionsFile[i].id})`, 'info'); | ||
|
||
context.subscriptionsFile.splice(i, 1); | ||
sandbox.__engine.__subscriptionsFile--; | ||
return true; | ||
|
@@ -1686,6 +1693,9 @@ function sandBox(script, name, verbose, debug, context) { | |
if (context.subscriptionsFile[i].id === idOrObject && context.subscriptionsFile[i].fileNamePattern === fileNamePattern) { | ||
deleted++; | ||
unsubscribeFile(script, context.subscriptionsFile[i].id, context.subscriptionsFile[i].fileNamePattern); | ||
|
||
sandbox.verbose && sandbox.log(`offFile(type=string, fileNamePattern=${fileNamePattern}, removing id=${context.subscriptionsFile[i].id})`, 'info'); | ||
|
||
context.subscriptionsFile.splice(i, 1); | ||
sandbox.__engine.__subscriptionsFile--; | ||
} | ||
|