Skip to main content

Overview

Returns a function to send structured log messages to the host for debugging and monitoring.

Import

import { useSendLog } from 'sunpeak';

Signature

function useSendLog(): (params: SendLogParams) => void

SendLogParams

level
LogLevel
required
Log level: 'debug' | 'info' | 'warning' | 'error' | 'critical'
data
unknown
required
Log data payload.
logger
string
Logger name for categorization.

Returns

sendLog
(params: SendLogParams) => void
Function to send a log message to the host.

Usage

import { useSendLog } from 'sunpeak';

function MyResource() {
  const sendLog = useSendLog();

  const handleAction = () => {
    sendLog({ level: 'info', data: { action: 'button_clicked' }, logger: 'MyResource' });
  };

  return <button onClick={handleAction}>Click Me</button>;
}