Custom logging

By default, SDKs output info and error logs to the console. But you can provide a custom logging callback to capture and forward logs elsewhere, e.g. to your monitoring infrastructure.

Pass the localLogger option in the call to initHypertune:

import { initHypertune } from "./generated/hypertune";

const hypertune = initHypertune({}, {
  token: process.env.NEXT_PUBLIC_HYPERTUNE_TOKEN!,
  localLogger: (level, message, metadata) => {
    console.log(level, message, metadata);
  }
});

export default hypertune;

localLogger?: (
  level: LogLevel,
  message: string,
  metadata: Record<string, unknown>
) => void;

enum LogLevel {
  Debug = 'Debug',
  Error = 'Error',
  Info = 'Info',
  Warn = 'Warn'
}

Last updated