UserSpice_getLogs (function)

Last updated: Fri, May 26, 2023 10:11 am
Return to Knowledgebase

Purpose

The UserSpice_getLogs function is a function in the UserSpice framework that retrieves logs from the database based on the provided options.

Location

users/helpers/us_helpers.php

Parameters

# Parameter Data Type Required Description
1 $opts = [] array Yes An array of options for retrieving logs (optional). * Available options: * - preset: string specifying a preset filter for logs (e.g., "diag"). * - limit: an integer or string specifying the maximum number of logs to retrieve (e.g., 1000 or "LIMIT 5000").

Returns

Data Type Description of Returned Data
array An array of log entries retrieved from the database.

Further Documentation:

// Retrieve all logs with the default options
$logs = UserSpice_getLogs();

// Retrieve logs with a preset filter and limit
$opts = [
'preset' => 'debug',
'limit' => 1000
];
$logs = UserSpice_getLogs($opts);



In the example above, the function is called without any options, which retrieves all logs with a default limit of 5000. In the second example, a preset filter of 'debug' is applied, which retrieves logs with the log type "Redirect Diag" or "Form Data", and a limit of 1000 logs.