remove option to anonymize

This commit is contained in:
Bruno Windels 2021-02-16 18:29:42 +01:00
parent 90cfcad5f1
commit 338f628627
3 changed files with 7 additions and 27 deletions

View File

@ -21,20 +21,10 @@ export class BaseLogger {
constructor({platform}) { constructor({platform}) {
this._openItems = new Set(); this._openItems = new Set();
this._platform = platform; this._platform = platform;
this._anonymize = false; //await platform.settingsStorage.getBool("anonymize", false);
}
get anonymize() {
return this._anonymize;
}
set anonymize(value) {
this._anonymize = !!value;
this._platform.settingsStorage.setBool("anonymize", this._anonymize);
} }
run(labelOrValues, callback, logLevel = LogLevel.Info, filterCreator = null) { run(labelOrValues, callback, logLevel = LogLevel.Info, filterCreator = null) {
const item = new LogItem(labelOrValues, logLevel, null, this._platform, this._anonymize); const item = new LogItem(labelOrValues, logLevel, null, this._platform.clock);
this._openItems.add(item); this._openItems.add(item);
const finishItem = () => { const finishItem = () => {

View File

@ -17,10 +17,9 @@ limitations under the License.
import {LogLevel, LogFilter} from "./LogFilter.js"; import {LogLevel, LogFilter} from "./LogFilter.js";
export class LogItem { export class LogItem {
constructor(labelOrValues, logLevel, filterCreator, platform, anonymize) { constructor(labelOrValues, logLevel, filterCreator, clock) {
this._platform = platform; this._clock = clock;
this._anonymize = anonymize; this._start = clock.now();
this._start = platform.clock.now();
this._end = null; this._end = null;
this._values = typeof labelOrValues === "string" ? {l: labelOrValues} : labelOrValues; this._values = typeof labelOrValues === "string" ? {l: labelOrValues} : labelOrValues;
this.error = null; this.error = null;
@ -65,15 +64,6 @@ export class LogItem {
} }
} }
anonymize(value) {
if (this._anonymize) {
const buffer = this._platform.crypto.digest("SHA-256", this._platform.encoding.utf8.encode(value));
return this._platform.encoding.base64.encode(buffer);
} else {
return value;
}
}
serialize(filter, depth) { serialize(filter, depth) {
if (this._filterCreator) { if (this._filterCreator) {
filter = this._filterCreator(new LogFilter(filter), this); filter = this._filterCreator(new LogFilter(filter), this);
@ -165,7 +155,7 @@ export class LogItem {
c.finish(); c.finish();
} }
} }
this._end = this._platform.clock.now(); this._end = this._clock.now();
} }
} }
@ -185,7 +175,7 @@ export class LogItem {
if (this._end !== null) { if (this._end !== null) {
console.trace("log item is finished, additional logs will likely not be recorded"); console.trace("log item is finished, additional logs will likely not be recorded");
} }
const item = new LogItem(labelOrValues, logLevel, filterCreator, this._platform, this._anonymize); const item = new LogItem(labelOrValues, logLevel, filterCreator, this._clock);
if (this._children === null) { if (this._children === null) {
this._children = []; this._children = [];
} }

View File

@ -193,7 +193,7 @@ export class Sync {
const isInitialSync = !syncToken; const isInitialSync = !syncToken;
syncToken = response.next_batch; syncToken = response.next_batch;
log.set("syncToken", log.anonymize(syncToken)); log.set("syncToken", syncToken);
log.set("status", this._status.get()); log.set("status", this._status.get());
const roomStates = this._parseRoomsResponse(response.rooms, isInitialSync); const roomStates = this._parseRoomsResponse(response.rooms, isInitialSync);