consoleInterceptor = (state) => {
  const handle = (printer, level, message, optionalParams) => {
    printer(message, ...optionalParams);
    if (state.hasJoinedLogSockets && state.logLevel >= level) {
      const s = ppVal(message);
      state.emitLog(
        state.tenant || "public",
        level,
        optionalParams.length === 0
          ? s
          : `${s} ${optionalParams.map((val) => ppVal(val)).join(" ")}`
      );
    }
  };
  return {
    log: (message, ...optionalParams) =>
      handle(console.log, 5, message, optionalParams),
    info: (message, ...optionalParams) =>
      handle(console.info, 5, message, optionalParams),
    debug: (message, ...optionalParams) =>
      handle(console.debug, 5, message, optionalParams),
    warn: (message, ...optionalParams) =>
      handle(console.warn, 2, message, optionalParams),
    error: (message, ...optionalParams) =>
      handle(console.error, 1, message, optionalParams),
  };
}
Action description
@category saltcorn-data
@module base-plugin/actions
@subcategory base-plugin