Upgrading to new adapter interface
This commit is contained in:
@ -1,14 +1,20 @@
|
||||
import { Lock } from "@hibas123/utils";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { Adapter, Message, Formatted } from "@hibas123/logging";
|
||||
import { Adapter, Message, Formatted, LoggingTypes } from "@hibas123/logging";
|
||||
|
||||
const MAX_FILE_SIZE = 500000000;
|
||||
|
||||
export class LoggingFiles implements Adapter {
|
||||
level = LoggingTypes.Debug;
|
||||
|
||||
file: Files;
|
||||
constructor(private filename: string, private maxFileSize = MAX_FILE_SIZE) {}
|
||||
|
||||
setLevel(level: LoggingTypes) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
init() {
|
||||
if (!this.file) {
|
||||
this.file = Files.getFile(this.filename);
|
||||
@ -41,11 +47,7 @@ const Debounce = (callback: () => void, iv = 500, max = 100) => {
|
||||
trigger: () => {
|
||||
curr++;
|
||||
if (curr >= max) {
|
||||
if (to) {
|
||||
clearTimeout(to);
|
||||
to = undefined;
|
||||
}
|
||||
curr = 0;
|
||||
curr = 0; // not clearing timeout, since this is a very high cost operation
|
||||
callback();
|
||||
} else if (!to) {
|
||||
to = setTimeout(() => {
|
||||
@ -55,6 +57,7 @@ const Debounce = (callback: () => void, iv = 500, max = 100) => {
|
||||
}, iv);
|
||||
}
|
||||
},
|
||||
close: () => {},
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user