export { FileAdapter } from "./filewriter";
import { FileAdapter } from "./filewriter";
import { LoggingBase } from "@hibas123/logging";
import Logging from "@hibas123/logging";

LoggingBase.nativeFunctions = {
   startTimer: () => {
      if (process.hrtime.bigint) {
         return process.hrtime.bigint();
      } else {
         return process.hrtime();
      }
   },
   diffTime: (start, end) => {
      if (process.hrtime.bigint) {
         return Number((BigInt(end) - BigInt(start)) / BigInt(1000)) / 1000;
      } else {
         let diff = process.hrtime(start);
         return diff[0] * 1000 + diff[1] / 1000000;
      }
   },
   endTimer: (start) => {
      if (process.hrtime.bigint) {
         return Number((process.hrtime.bigint() - start) / BigInt(1000)) / 1000;
      } else {
         let diff = process.hrtime(start);
         return diff[0] * 1000 + diff[1] / 1000000;
      }
   },
};

export const DefaultFileAdapter = new FileAdapter("./logs/all.log");

Logging.addAdapter(DefaultFileAdapter);

export default Logging;
