From cd05e1e0e66bba24e9edff24113e9c81c6296ed4 Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Thu, 1 Jun 2023 08:48:41 -0400 Subject: [PATCH] Add fileLogging launch.json option (#487) * Add fileLogging launch.json optoin * Add telemetry tracking for logfilePath * roku-debug@0.19.0 --- package-lock.json | 20 ++--- package.json | 122 +++++++++++++++++++++++++++++- src/DebugConfigurationProvider.ts | 1 + src/managers/TelemetryManager.ts | 7 +- 4 files changed, 139 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index e6da2fd0..a1a5eb96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "node-ssdp": "^4.0.0", "postman-request": "^2.88.1-postman.32", "pretty-bytes": "^5.6.0", - "roku-debug": "^0.18.12", + "roku-debug": "^0.19.0", "roku-deploy": "^3.10.2", "roku-test-automation": "^2.0.0-beta.19", "semver": "^7.1.3", @@ -8874,15 +8874,16 @@ } }, "node_modules/roku-debug": { - "version": "0.18.12", - "resolved": "https://registry.npmjs.org/roku-debug/-/roku-debug-0.18.12.tgz", - "integrity": "sha512-tBRMd0LBIUnMNQGBlETlnyQDu9Z0x6qa/d4CM9SdoGSfqJ5RkWAx5xziYKsGlfqU0MOAMjBDhcPV+JeJJR5bvw==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/roku-debug/-/roku-debug-0.19.0.tgz", + "integrity": "sha512-HnAS6y8WG+Y9alJ9oWGlzjlElzKsf1nk5fxVk3l4yzrV/GruL4kXW+l2QrCa30T95jS9Yp/mS9PsmBjspMIJ3w==", "dependencies": { "@rokucommunity/logger": "^0.3.3", "brighterscript": "^0.65.0", - "dateformat": "^4.6.3", + "dateformat": "~4", "eol": "^0.9.1", "eventemitter3": "^4.0.7", + "fast-glob": "^3.2.11", "find-in-files": "^0.5.0", "fs-extra": "^10.0.0", "natural-orderby": "^2.0.3", @@ -18326,15 +18327,16 @@ } }, "roku-debug": { - "version": "0.18.12", - "resolved": "https://registry.npmjs.org/roku-debug/-/roku-debug-0.18.12.tgz", - "integrity": "sha512-tBRMd0LBIUnMNQGBlETlnyQDu9Z0x6qa/d4CM9SdoGSfqJ5RkWAx5xziYKsGlfqU0MOAMjBDhcPV+JeJJR5bvw==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/roku-debug/-/roku-debug-0.19.0.tgz", + "integrity": "sha512-HnAS6y8WG+Y9alJ9oWGlzjlElzKsf1nk5fxVk3l4yzrV/GruL4kXW+l2QrCa30T95jS9Yp/mS9PsmBjspMIJ3w==", "requires": { "@rokucommunity/logger": "^0.3.3", "brighterscript": "^0.65.0", - "dateformat": "^4.6.3", + "dateformat": "~4", "eol": "^0.9.1", "eventemitter3": "^4.0.7", + "fast-glob": "^3.2.11", "find-in-files": "^0.5.0", "fs-extra": "^10.0.0", "natural-orderby": "^2.0.3", diff --git a/package.json b/package.json index deb76d1d..2b1f0700 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "node-ssdp": "^4.0.0", "postman-request": "^2.88.1-postman.32", "pretty-bytes": "^5.6.0", - "roku-debug": "^0.18.12", + "roku-debug": "^0.19.0", "roku-deploy": "^3.10.2", "roku-test-automation": "^2.0.0-beta.19", "semver": "^7.1.3", @@ -511,6 +511,123 @@ ] } }, + "fileLogging": { + "oneOf": [ + { + "type": "object", + "description": "Configure file logging for debug console logs as well as RokuCommunity debugger logs", + "default": { + "dir": "${workspaceFolder}/logs", + "rokuDevice": { + "enabled": true, + "filename": "rokuDevice.log", + "mode": "session", + "logLimit": 5 + }, + "debugger": { + "enabled": true, + "filename": "debugger.log", + "mode": "session", + "logLimit": 5 + } + }, + "properties": { + "enabled": { + "type": "boolean", + "description": "Should file logging be enabled" + }, + "dir": { + "type": "string", + "description": "Directory where log files should be stored. used when filename is relative", + "default": "${workspaceFolder}/logs" + }, + "logLimit": { + "type": "number", + "description": "The number of log files to keep. `null` means keep all logs", + "default": null + }, + "rokuDevice": { + "oneOf": [ + { + "type": "object", + "description": "File logging for the telnet or IO output from the Roku device currently being debugged. (i.e. all the stuff produced by `print` statements in your code)", + "properties": { + "enabled": { + "type": "boolean", + "description": "Should file logging be enabled" + }, + "dir": { + "type": "string", + "description": "Directory where log files should be stored. used when filename is relative", + "default": "${workspaceFolder}/logs" + }, + "logLimit": { + "type": "number", + "description": "The number of log files to keep. `null` means keep all logs", + "default": null + }, + "mode": { + "type": "string", + "description": "`'session'` means a unique timestamped file will be created on every debug session.`'append'` means all logs will be appended to a single file", + "default": "session", + "enum": [ + "session", + "append" + ] + } + } + }, + { + "type": "boolean", + "description": "Enable file logging for debug console logs as well as RokuCommunity debugger logs" + } + ] + }, + "debugger": { + "oneOf": [ + { + "type": "object", + "description": "File logging for the debugger. Mostly used to provide crash logs to the RokuCommunity team.", + "properties": { + "enabled": { + "type": "boolean", + "description": "Should file logging be enabled" + }, + "dir": { + "type": "string", + "description": "Directory where log files should be stored. used when filename is relative", + "default": "${workspaceFolder}/logs" + }, + "logLimit": { + "type": "number", + "description": "The number of log files to keep. `null` means keep all logs", + "default": null + }, + "mode": { + "type": "string", + "description": "`'session'` means a unique timestamped file will be created on every debug session.`'append'` means all logs will be appended to a single file", + "default": "session", + "enum": [ + "session", + "append" + ] + } + } + }, + { + "type": "boolean", + "description": "Enable file logging for debug console logs as well as RokuCommunity debugger logs" + } + ] + } + } + }, + { + "type": "boolean", + "description": "Enable file logging for debug console logs as well as RokuCommunity debugger logs" + } + ] + }, "outDir": { "type": "string", "description": "The folder where the the build artifacts are placed (like the staging folder and .zip files of the apps)", @@ -650,6 +767,7 @@ }, "logfilePath": { "type": "string", + "deprecationMessage": "Use `fileLogging` option instead", "description": "A path to a file where all brightscript console output will be written. If null or empty, file logging will be disabled." }, "enableDebugProtocol": { @@ -1655,6 +1773,7 @@ }, "brightscript.debug.logfilePath": { "type": "string", + "deprecationMessage": "Use `fileLogging` option instead", "description": "A path to a file where all brightscript console output will be written. If null or empty, file logging will be disabled.", "scope": "resource" }, @@ -2023,6 +2142,7 @@ "properties": { "brightscript.extensionLogfilePath": { "type": "string", + "deprecationMessage": "Use `fileLogging` option instead", "description": "File where the 'BrightScript Extension' output panel (i.e. debug logs for the extension) will be appended. If omitted, no file logging will be done. ${workspaceFolder} is supported and will point to the first workspace found.", "scope": "resource" } diff --git a/src/DebugConfigurationProvider.ts b/src/DebugConfigurationProvider.ts index 3e8e83b7..951af8e3 100644 --- a/src/DebugConfigurationProvider.ts +++ b/src/DebugConfigurationProvider.ts @@ -238,6 +238,7 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio config.remotePort = config.remotePort ? config.remotePort : this.configDefaults.remotePort; config.logfilePath ??= null; config.enableDebugProtocol = config.enableDebugProtocol ? true : false; + config.cwd = folderUri.fsPath; if (config.request !== 'launch') { await vscode.window.showErrorMessage(`roku-debug only supports the 'launch' request type`); diff --git a/src/managers/TelemetryManager.ts b/src/managers/TelemetryManager.ts index 4740afeb..64fa20eb 100644 --- a/src/managers/TelemetryManager.ts +++ b/src/managers/TelemetryManager.ts @@ -2,6 +2,7 @@ import TelemetryReporter from '@vscode/extension-telemetry'; import type { Disposable } from 'vscode'; import type { BrightScriptLaunchConfiguration } from '../DebugConfigurationProvider'; import type { RemoteControlModeInitiator } from './RemoteControlManager'; +import * as vscode from 'vscode'; const APP_INSIGHTS_KEY = '8618f206-4732-4729-88ed-d07dcf17f199'; @@ -40,7 +41,11 @@ export class TelemetryManager implements Disposable { isPreLaunchTaskDefined: isDefined(event.preLaunchTask), isComponentLibrariesDefined: isDefined(event.componentLibraries), isDeepLinkUrlDefined: isDefined(event.deepLinkUrl), - isStagingFolderPathDefined: isDefined(event.stagingFolderPath) + isStagingFolderPathDefined: isDefined(event.stagingFolderPath), + isLogfilePathDefined: isDefined(event.logfilePath), + isExtensionLogfilePathDefined: isDefined( + vscode.workspace.getConfiguration('brightscript').get('extensionLogfilePath') + ) }); }