Files
plexjs/docs/sdks/log

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";

async function run() {
  const sdk = new PlexAPI({
    accessToken: "<YOUR_API_KEY_HERE>",
  });

  const level = Level.Three;
  const message = "string";
  const source = "string";
  
  const res = await sdk.log.logLine(level, message, source);

  if (res?.statusCode !== 200) {
    throw new Error("Unexpected status code: " + res?.statusCode || "-");
  }
  
  // handle response
}

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 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

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

async function run() {
  const sdk = new PlexAPI({
    accessToken: "<YOUR_API_KEY_HERE>",
  });

  const res = await sdk.log.logMultiLine();

  if (res?.statusCode !== 200) {
    throw new Error("Unexpected status code: " + res?.statusCode || "-");
  }
  
  // handle response
}

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.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";

async function run() {
  const sdk = new PlexAPI({
    accessToken: "<YOUR_API_KEY_HERE>",
  });

  const res = await sdk.log.enablePaperTrail();

  if (res?.statusCode !== 200) {
    throw new Error("Unexpected status code: " + res?.statusCode || "-");
  }
  
  // handle response
}

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 /