Documentation

AiLoggingTrait

Table of Contents

Properties

$_log_id  : int|null
$_time_start  : float

Methods

logAndThrowException()  : SproutAiApiRequest
Simple response logging wrapper to call in case of error
logError()  : SproutAiApiRequest
Simple response logging wrapper to call in case of error
logRequest()  : SproutAiApiRequest
Log a request on its way out to a provider
logResponse()  : SproutAiApiRequest
Log a response from a provider. Associate with current request if possible.

Properties

Methods

logAndThrowException()

Simple response logging wrapper to call in case of error

public static logAndThrowException(string $function, string $endpoint, Exception $e) : SproutAiApiRequest
Parameters
$function : string

The FUNCTION being ran at call time

$endpoint : string

The provider endpoint we're calling

$e : Exception

The exception thrown

Return values
SproutAiApiRequest

logError()

Simple response logging wrapper to call in case of error

public static logError(string $function, string $endpoint, array<string|int, mixed> $data) : SproutAiApiRequest
Parameters
$function : string

The FUNCTION being ran at call time

$endpoint : string

The provider endpoint we're calling

$data : array<string|int, mixed>

The response data

Return values
SproutAiApiRequest

logRequest()

Log a request on its way out to a provider

public static logRequest(string $function, string $endpoint, array<string|int, mixed> $data) : SproutAiApiRequest
Parameters
$function : string

The FUNCTION being ran at call time, if part of a class

$endpoint : string

The provider endpoint we're calling

$data : array<string|int, mixed>

The request data

Return values
SproutAiApiRequest

logResponse()

Log a response from a provider. Associate with current request if possible.

public static logResponse(string $function, string $endpoint, array<string|int, mixed> $data[, bool $error = false ]) : SproutAiApiRequest

Use self::$logError() for error responses

Parameters
$function : string

The FUNCTION being ran at call time

$endpoint : string

The provider endpoint we're calling

$data : array<string|int, mixed>

The response data

$error : bool = false

Whether this is an error response. Auto set via self::$logError()

Return values
SproutAiApiRequest
On this page

Search results