import { useMemoizedFn } from 'ahooks';
import useEngineContext from "../../../../hooks/useEngineContext";
export var usePeripheralLogger = function usePeripheralLogger() {
  var context = useEngineContext();
  var getAppInstance = useMemoizedFn(function () {
    var _context$appHelper, _context$appHelper$ge;
    return context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 || (_context$appHelper$ge = _context$appHelper.getApp) === null || _context$appHelper$ge === void 0 ? void 0 : _context$appHelper$ge.call(_context$appHelper);
  });
  var addLog = useMemoizedFn(function (title, metadata) {
    var _getAppInstance, _getAppInstance$addLo;
    var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
    (_getAppInstance = getAppInstance()) === null || _getAppInstance === void 0 || (_getAppInstance = _getAppInstance.logger) === null || _getAppInstance === void 0 || (_getAppInstance$addLo = _getAppInstance.addLog) === null || _getAppInstance$addLo === void 0 || _getAppInstance$addLo.call(_getAppInstance, {
      type: type,
      title: title,
      metadata: metadata
    });
  });
  return {
    addLog: addLog
  };
};
export default usePeripheralLogger;