# Log (*log*) ## Overview Logging mechanism to allow clients to log to the server ### Available Operations * [writeLog](#writelog) - Logging a multi-line message to the Plex Media Server log * [writeMessage](#writemessage) - Logging a single-line message to the Plex Media Server log * [enablePapertrail](#enablepapertrail) - Enabling Papertrail ## writeLog 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 PUT endpoint as a linefeed-separated block of POST data. The parameters for each query string match as above. ### Example Usage ```typescript import { PlexAPI } from "@lukehagar/plexjs"; import { openAsBlob } from "node:fs"; const plexAPI = new PlexAPI(); async function run() { const result = await plexAPI.log.writeLog(await openAsBlob("example.file")); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { PlexAPICore } from "@lukehagar/plexjs/core.js"; import { logWriteLog } from "@lukehagar/plexjs/funcs/logWriteLog.js"; import { openAsBlob } from "node:fs"; // Use `PlexAPICore` for best tree-shaking performance. // You can create one instance of it to use across an application. const plexAPI = new PlexAPICore(); async function run() { const res = await logWriteLog(plexAPI, await openAsBlob("example.file")); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("logWriteLog failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [ReadableStream](../../models/.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.WriteLogResponse](../../sdk/models/operations/writelogresponse.md)\>** ### Errors | Error Type | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4XX, 5XX | \*/\* | ## writeMessage This endpoint will write a single-line log message, including a level and source to the main Plex Media Server log. Note: This endpoint responds to all HTTP verbs **except POST** but PUT is preferred ### Example Usage ```typescript import { PlexAPI } from "@lukehagar/plexjs"; const plexAPI = new PlexAPI({ xPlexClientIdentifier: "abc123", xPlexProduct: "Plex for Roku", xPlexVersion: "2.4.1", xPlexPlatform: "Roku", xPlexPlatformVersion: "4.3 build 1057", xPlexDevice: "Roku 3", xPlexModel: "4200X", xPlexDeviceVendor: "Roku", xPlexDeviceName: "Living Room TV", xPlexMarketplace: "googlePlay", }); async function run() { const result = await plexAPI.log.writeMessage({}); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { PlexAPICore } from "@lukehagar/plexjs/core.js"; import { logWriteMessage } from "@lukehagar/plexjs/funcs/logWriteMessage.js"; // Use `PlexAPICore` for best tree-shaking performance. // You can create one instance of it to use across an application. const plexAPI = new PlexAPICore({ xPlexClientIdentifier: "abc123", xPlexProduct: "Plex for Roku", xPlexVersion: "2.4.1", xPlexPlatform: "Roku", xPlexPlatformVersion: "4.3 build 1057", xPlexDevice: "Roku 3", xPlexModel: "4200X", xPlexDeviceVendor: "Roku", xPlexDeviceName: "Living Room TV", xPlexMarketplace: "googlePlay", }); async function run() { const res = await logWriteMessage(plexAPI, {}); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("logWriteMessage failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.WriteMessageRequest](../../sdk/models/operations/writemessagerequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.WriteMessageResponse](../../sdk/models/operations/writemessageresponse.md)\>** ### Errors | Error Type | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4XX, 5XX | \*/\* | ## enablePapertrail This endpoint will enable all Plex Media Server logs to be sent to the Papertrail networked logging site for a period of time Note: This endpoint responds to all HTTP verbs but POST is preferred ### Example Usage ```typescript import { PlexAPI } from "@lukehagar/plexjs"; const plexAPI = new PlexAPI({ xPlexClientIdentifier: "abc123", xPlexProduct: "Plex for Roku", xPlexVersion: "2.4.1", xPlexPlatform: "Roku", xPlexPlatformVersion: "4.3 build 1057", xPlexDevice: "Roku 3", xPlexModel: "4200X", xPlexDeviceVendor: "Roku", xPlexDeviceName: "Living Room TV", xPlexMarketplace: "googlePlay", }); async function run() { const result = await plexAPI.log.enablePapertrail({}); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { PlexAPICore } from "@lukehagar/plexjs/core.js"; import { logEnablePapertrail } from "@lukehagar/plexjs/funcs/logEnablePapertrail.js"; // Use `PlexAPICore` for best tree-shaking performance. // You can create one instance of it to use across an application. const plexAPI = new PlexAPICore({ xPlexClientIdentifier: "abc123", xPlexProduct: "Plex for Roku", xPlexVersion: "2.4.1", xPlexPlatform: "Roku", xPlexPlatformVersion: "4.3 build 1057", xPlexDevice: "Roku 3", xPlexModel: "4200X", xPlexDeviceVendor: "Roku", xPlexDeviceName: "Living Room TV", xPlexMarketplace: "googlePlay", }); async function run() { const res = await logEnablePapertrail(plexAPI, {}); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("logEnablePapertrail failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.EnablePapertrailRequest](../../sdk/models/operations/enablepapertrailrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.EnablePapertrailResponse](../../sdk/models/operations/enablepapertrailresponse.md)\>** ### Errors | Error Type | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4XX, 5XX | \*/\* |