Add void return types as well
This commit is contained in:
parent
5efa27c2a3
commit
2d8b719ab0
2 changed files with 17 additions and 16 deletions
|
@ -51,18 +51,18 @@ export class IDBLogger extends BaseLogger {
|
|||
this._flushInterval = this._platform.clock.createInterval(() => this._tryFlush(), flushInterval);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
dispose(): void {
|
||||
window.removeEventListener("pagehide", this, false);
|
||||
this._flushInterval.dispose();
|
||||
}
|
||||
|
||||
handleEvent(evt: Event) {
|
||||
handleEvent(evt: Event): void {
|
||||
if (evt.type === "pagehide") {
|
||||
this._finishAllAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
async _tryFlush() {
|
||||
async _tryFlush(): Promise<void> {
|
||||
const db = await this._openDB();
|
||||
try {
|
||||
const txn = db.transaction(["logs"], "readwrite");
|
||||
|
@ -92,7 +92,7 @@ export class IDBLogger extends BaseLogger {
|
|||
}
|
||||
}
|
||||
|
||||
_finishAllAndFlush() {
|
||||
_finishAllAndFlush(): void {
|
||||
this._finishOpenItems();
|
||||
this.log({l: "pagehide, closing logs", t: "navigation"});
|
||||
this._persistQueuedItems(this._queuedItems);
|
||||
|
@ -116,14 +116,14 @@ export class IDBLogger extends BaseLogger {
|
|||
return openDatabase(this._name, db => db.createObjectStore("logs", {keyPath: "id", autoIncrement: true}), 1);
|
||||
}
|
||||
|
||||
_persistItem(logItem: LogItem, filter: LogFilter, forced: boolean) {
|
||||
_persistItem(logItem: LogItem, filter: LogFilter, forced: boolean): void {
|
||||
const serializedItem = logItem.serialize(filter, undefined, forced);
|
||||
this._queuedItems.push({
|
||||
json: JSON.stringify(serializedItem)
|
||||
});
|
||||
}
|
||||
|
||||
_persistQueuedItems(items: QueuedItem[]) {
|
||||
_persistQueuedItems(items: QueuedItem[]): void {
|
||||
try {
|
||||
window.localStorage.setItem(`${this._name}_queuedItems`, JSON.stringify(items));
|
||||
} catch (e) {
|
||||
|
@ -146,7 +146,7 @@ export class IDBLogger extends BaseLogger {
|
|||
}
|
||||
}
|
||||
|
||||
async _removeItems(items: QueuedItem[]) {
|
||||
async _removeItems(items: QueuedItem[]): Promise<void> {
|
||||
const db = await this._openDB();
|
||||
try {
|
||||
const txn = db.transaction(["logs"], "readwrite");
|
||||
|
@ -186,7 +186,7 @@ class IDBLogExport {
|
|||
/**
|
||||
* @return {Promise}
|
||||
*/
|
||||
removeFromStore() {
|
||||
removeFromStore(): Promise<void> {
|
||||
return this._logger._removeItems(this._items);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,18 +75,18 @@ export class LogItem {
|
|||
}
|
||||
|
||||
/** start a new detached root log item and log a reference to it from this item */
|
||||
wrapDetached(labelOrValues: LabelOrValues, callback: LogCallback, logLevel: LogLevelOrNull, filterCreator: FilterCreator) {
|
||||
wrapDetached(labelOrValues: LabelOrValues, callback: LogCallback, logLevel: LogLevelOrNull, filterCreator: FilterCreator): void {
|
||||
this.refDetached(this.runDetached(labelOrValues, callback, logLevel, filterCreator));
|
||||
}
|
||||
|
||||
/** logs a reference to a different log item, usually obtained from runDetached.
|
||||
This is useful if the referenced operation can't be awaited. */
|
||||
refDetached(logItem: LogItem, logLevel: LogLevelOrNull = null) {
|
||||
refDetached(logItem: LogItem, logLevel: LogLevelOrNull = null): void {
|
||||
logItem.ensureRefId();
|
||||
this.log({ref: logItem._values.refId as number}, logLevel);
|
||||
}
|
||||
|
||||
ensureRefId() {
|
||||
ensureRefId(): void {
|
||||
if (!this._values.refId) {
|
||||
this.set("refId", this._logger._createRefId());
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ export class LogItem {
|
|||
/**
|
||||
* Creates a new child item and runs it in `callback`.
|
||||
*/
|
||||
wrap(labelOrValues: LabelOrValues, callback: LogCallback, logLevel: LogLevelOrNull = null, filterCreator: FilterCreator = null) {
|
||||
wrap(labelOrValues: LabelOrValues, callback: LogCallback, logLevel: LogLevelOrNull = null, filterCreator: FilterCreator = null): unknown {
|
||||
const item = this.child(labelOrValues, logLevel, filterCreator);
|
||||
return item.run(callback);
|
||||
}
|
||||
|
@ -136,12 +136,12 @@ export class LogItem {
|
|||
*
|
||||
* Hence, the child item is not returned.
|
||||
*/
|
||||
log(labelOrValues: LabelOrValues, logLevel: LogLevelOrNull = null) {
|
||||
log(labelOrValues: LabelOrValues, logLevel: LogLevelOrNull = null): void {
|
||||
const item = this.child(labelOrValues, logLevel, null);
|
||||
item.end = item.start;
|
||||
}
|
||||
|
||||
set(key: string | object, value: unknown) {
|
||||
set(key: string | object, value: unknown): void {
|
||||
if(typeof key === "object") {
|
||||
const values = key;
|
||||
Object.assign(this._values, values);
|
||||
|
@ -150,6 +150,7 @@ export class LogItem {
|
|||
}
|
||||
}
|
||||
|
||||
// todo: null or undefined here?
|
||||
serialize(filter: LogFilter, parentStartTime: number | null = null, forced: boolean): ISerializedItem | null {
|
||||
if (this._filterCreator) {
|
||||
try {
|
||||
|
@ -243,7 +244,7 @@ export class LogItem {
|
|||
* finished the item, recording the end time. After finishing, an item can't be modified anymore as it will be persisted.
|
||||
* @internal shouldn't typically be called by hand. allows to force finish if a promise is still running when closing the app
|
||||
*/
|
||||
finish() {
|
||||
finish(): void {
|
||||
if (this.end === null) {
|
||||
if (this._children !== null) {
|
||||
for(const c of this._children) {
|
||||
|
@ -281,7 +282,7 @@ export class LogItem {
|
|||
return item;
|
||||
}
|
||||
|
||||
get logger() {
|
||||
get logger(): BaseLogger {
|
||||
return this._logger;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue