mirror of
https://github.com/LukeHagar/plexphp.git
synced 2025-12-09 20:47:46 +00:00
Log
Overview
Submit logs to the Log Handler for Plex Media Server
Available Operations
- logLine - Logging a single line message.
- logMultiLine - Logging a multi-line message
- enablePaperTrail - Enabling Papertrail
logLine
This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log.
Example Usage
<?php
declare(strict_types=1);
require_once 'vendor/autoload.php';
use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
use \LukeHagar\Plex_API\Models\Operations;
$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();
try {
$response = $sdk->log->logLine(Operations\Level::Three, 'string', 'string');
if ($response->statusCode === 200) {
// handle response
}
} catch (Exception $e) {
// handle exception
}
Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
level |
\LukeHagar\Plex_API\Models\Operations\Level | ✔️ | An integer log level to write to the PMS log with. 0: Error 1: Warning 2: Info 3: Debug 4: Verbose |
|
message |
string | ✔️ | The text of the message to write to the log. | |
source |
string | ✔️ | a string indicating the source of the message. |
Response
?\LukeHagar\Plex_API\Models\Operations\LogLineResponse
logMultiLine
This endpoint will write multiple lines to the main Plex Media Server log in a single request. It takes a set of query strings as would normally sent to the above GET endpoint as a linefeed-separated block of POST data. The parameters for each query string match as above.
Example Usage
<?php
declare(strict_types=1);
require_once 'vendor/autoload.php';
use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();
try {
$response = $sdk->log->logMultiLine();
if ($response->statusCode === 200) {
// handle response
}
} catch (Exception $e) {
// handle exception
}
Response
?\LukeHagar\Plex_API\Models\Operations\LogMultiLineResponse
enablePaperTrail
This endpoint will enable all Plex Media Serverlogs to be sent to the Papertrail networked logging site for a period of time.
Example Usage
<?php
declare(strict_types=1);
require_once 'vendor/autoload.php';
use \LukeHagar\Plex_API;
use \LukeHagar\Plex_API\Models\Components;
$security = new Components\Security();
$security->accessToken = '<YOUR_API_KEY_HERE>';
$sdk = Plex_API\PlexAPI::builder()->setSecurity($security)->build();
try {
$response = $sdk->log->enablePaperTrail();
if ($response->statusCode === 200) {
// handle response
}
} catch (Exception $e) {
// handle exception
}
Response
?\LukeHagar\Plex_API\Models\Operations\EnablePaperTrailResponse