Skip to content

Commit

Permalink
AG-31746 stop using getText for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
maximtop committed Apr 16, 2024
1 parent dc9b5cb commit 4da4ad5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
17 changes: 3 additions & 14 deletions src/helpers/hit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,11 @@ export const hit = (source: Source) => {
const log = console.log.bind(console);
const trace = console.trace.bind(console);

let prefix = source.ruleText || '';

let prefix = '';
if (source.domainName) {
const AG_SCRIPTLET_MARKER = '#%#//';
const UBO_SCRIPTLET_MARKER = '##+js';
let ruleStartIndex;
if (source.ruleText.includes(AG_SCRIPTLET_MARKER)) {
ruleStartIndex = source.ruleText.indexOf(AG_SCRIPTLET_MARKER);
} else if (source.ruleText.includes(UBO_SCRIPTLET_MARKER)) {
ruleStartIndex = source.ruleText.indexOf(UBO_SCRIPTLET_MARKER);
}
// delete all domains from ruleText and leave just rule part
const rulePart = source.ruleText.slice(ruleStartIndex);
// prepare applied scriptlet rule for specific domain
prefix = `${source.domainName}${rulePart}`;
prefix += `${source.domainName}`;
}
prefix += `#%#//scriptlet(${source.name} + ${source.args.join(', ')})`;

log(`${prefix} trace start`);
if (trace) {
Expand Down
6 changes: 4 additions & 2 deletions types/scriptlets.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ declare module '@adguard/scriptlets' {
verbose: boolean;

/**
* Source rule text is used for debugging purposes
* Source rule text is used for debugging purposes.
*
* @deprecated since it is not used in the code anymore.
*/
ruleText: string;
ruleText?: string;

/**
* Domain name, used to improve logging
Expand Down

0 comments on commit 4da4ad5

Please sign in to comment.