Skip to content

Latest commit

 

History

History
169 lines (114 loc) · 17.1 KB

README.md

File metadata and controls

169 lines (114 loc) · 17.1 KB

Log

(log)

Overview

Submit logs to the Log Handler for Plex Media Server

Available Operations

logLine

This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";
import { Level } from "@lukehagar/plexjs/models/operations";

const plexAPI = new PlexAPI({
  accessToken: "<YOUR_API_KEY_HERE>",
  xPlexClientIdentifier: "Postman",
});

async function run() {
  const result = await plexAPI.log.logLine(Level.Three, "Test log message", "Postman");

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description Example
level 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. [object Object]
source string ✔️ a string indicating the source of the message. [object Object]
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.LogLineResponse>

Errors

Error Object Status Code Content Type
errors.LogLineResponseBody 401 application/json
errors.SDKError 4xx-5xx /

logMultiLine

This endpoint allows for the batch addition of log entries to the main Plex Media Server log.
It accepts a text/plain request body, where each line represents a distinct log entry.
Each log entry consists of URL-encoded key-value pairs, specifying log attributes such as 'level', 'message', and 'source'.

Log entries are separated by a newline character (\n).
Each entry's parameters should be URL-encoded to ensure accurate parsing and handling of special characters.
This method is efficient for logging multiple entries in a single API call, reducing the overhead of multiple individual requests.

The 'level' parameter specifies the log entry's severity or importance, with the following integer values:

  • 0: Error - Critical issues that require immediate attention.
  • 1: Warning - Important events that are not critical but may indicate potential issues.
  • 2: Info - General informational messages about system operation.
  • 3: Debug - Detailed information useful for debugging purposes.
  • 4: Verbose - Highly detailed diagnostic information for in-depth analysis.

The 'message' parameter contains the log text, and 'source' identifies the log message's origin (e.g., an application name or module).

Example of a single log entry format: level=4&message=Sample%20log%20entry&source=applicationName

Ensure each parameter is properly URL-encoded to avoid interpretation issues.

Example Usage

import { PlexAPI } from "@lukehagar/plexjs";

const plexAPI = new PlexAPI({
  accessToken: "<YOUR_API_KEY_HERE>",
  xPlexClientIdentifier: "Postman",
});

async function run() {
  const result = await plexAPI.log.logMultiLine("level=4&message=Test%20message%201&source=postman
  level=3&message=Test%20message%202&source=postman
  level=1&message=Test%20message%203&source=postman");

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request string ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.LogMultiLineResponse>

Errors

Error Object Status Code Content Type
errors.LogMultiLineResponseBody 401 application/json
errors.SDKError 4xx-5xx /

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

import { PlexAPI } from "@lukehagar/plexjs";

const plexAPI = new PlexAPI({
  accessToken: "<YOUR_API_KEY_HERE>",
  xPlexClientIdentifier: "Postman",
});

async function run() {
  const result = await plexAPI.log.enablePaperTrail();

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.EnablePaperTrailResponse>

Errors

Error Object Status Code Content Type
errors.EnablePaperTrailResponseBody 401 application/json
errors.SDKError 4xx-5xx /