diff --git a/README.md b/README.md index 8d096cb..286f52c 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,21 @@ A powerful command line utility for the Unity Game Engine. Automate Unity projec - [License Version](#license-version) - [Activate License](#activate-license) - [Return License](#return-license) + - [License Context](#license-context) + - [Licensing Logs](#licensing-logs) - [Unity Hub](#unity-hub) - [Hub Version](#hub-version) - [Hub Path](#hub-path) - [Unity Hub Install](#unity-hub-install) - [Run Unity Hub Commands](#run-unity-hub-commands) - - [Unity Editor](#unity-editor) - [Setup Unity Editor](#setup-unity-editor) - [Uninstall Unity Editor](#uninstall-unity-editor) + - [Unity Editor](#unity-editor) + - [Run Unity Editor Commands](#run-unity-editor-commands) - [List Project Templates](#list-project-templates) - [Create Unity Project](#create-unity-project) - [Open Unity Project](#open-unity-project) - - [Run Unity Editor Commands](#run-unity-editor-commands) + - [Unity Editor Logs](#unity-editor-logs) - [Unity Package Manager](#unity-package-manager) - [Sign a Unity Package](#sign-a-unity-package) - [Logging](#logging) @@ -110,7 +113,7 @@ unity-cli activate-license --license personal --email --password `: Run Unity Editor command line arguments (passes args directly to the editor). + +- `--unity-editor ` The path to the Unity Editor executable. If unspecified, `--unity-project` or the `UNITY_EDITOR_PATH` environment variable must be set. +- `--unity-project ` The path to a Unity project. If unspecified, the `UNITY_PROJECT_PATH` environment variable will be used, otherwise no project will be specified. +- `--log-name ` The name of the log file. +- `--log-level ` Override the logger verbosity (`debug`, `info`, `minimal`, `warning`, `error`). Defaults to `info`. +- `--verbose` Enable verbose logging. (Deprecated, use `--log-level ` instead) +- `` Arguments to pass directly to the Unity Editor executable. + +> [!NOTE] +> When setting the `--log-level` option to `minimal`, only the unity telemetry logs will be shown in the console output. All other logs will be written to the log file. This option is only supported when running the command locally in the terminal. ***This options is still experimental and may change in future releases.*** +> +> When running in CI environments the logger will automatically print the full logs to the console no matter the log level. + +```bash +unity-cli run --unity-project -quit -batchmode -executeMethod StartCommandLineBuild +``` + ##### List Project Templates > [!NOTE] @@ -274,24 +297,12 @@ unity-cli open-project --unity-project --unity-version 6000 -- unity-cli open-project ``` -##### Run Unity Editor Commands +##### Unity Editor Logs -`run [options] `: Run Unity Editor command line arguments (passes args directly to the editor). - -- `--unity-editor ` The path to the Unity Editor executable. If unspecified, `--unity-project` or the `UNITY_EDITOR_PATH` environment variable must be set. -- `--unity-project ` The path to a Unity project. If unspecified, the `UNITY_PROJECT_PATH` environment variable will be used, otherwise no project will be specified. -- `--log-name ` The name of the log file. -- `--log-level ` Override the logger verbosity (`debug`, `info`, `minimal`, `warning`, `error`). Defaults to `info`. -- `--verbose` Enable verbose logging. (Deprecated, use `--log-level ` instead) -- `` Arguments to pass directly to the Unity Editor executable. - -> [!NOTE] -> When setting the `--log-level` option to `minimal`, only the unity telemetry logs will be shown in the console output. All other logs will be written to the log file. This option is only supported when running the command locally in the terminal. ***This options is still experimental and may change in future releases.*** -> -> When running in CI environments the logger will automatically print the full logs to the console no matter the log level. +`editor-logs`: Prints the path to the Unity Editor log files. ```bash -unity-cli run --unity-project -quit -batchmode -executeMethod StartCommandLineBuild +unity-cli editor-logs ``` #### Unity Package Manager diff --git a/package-lock.json b/package-lock.json index 056f0e1..b517890 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.6.2", + "version": "1.6.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.6.2", + "version": "1.6.3", "license": "MIT", "dependencies": { "@electron/asar": "^4.0.1", diff --git a/package.json b/package.json index 09a0b05..27bb3c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rage-against-the-pixel/unity-cli", - "version": "1.6.2", + "version": "1.6.3", "description": "A command line utility for the Unity Game Engine.", "author": "RageAgainstThePixel", "license": "MIT", diff --git a/src/cli.ts b/src/cli.ts index 4ea39f5..f88837d 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -688,6 +688,14 @@ program.command('open-project') } }); +program.command('editor-logs') + .description('Prints the path to the Unity Editor log files.') + .action(async (options) => { + const unityEditorLogsPath = UnityEditor.GetEditorLogsDirectory(); + process.stdout.write(`${unityEditorLogsPath}\n`); + process.exit(0); + }); + program.commandsGroup("Unity Package Manager:"); program.command('sign-package') diff --git a/src/unity-editor.ts b/src/unity-editor.ts index 371654c..b3cd81f 100644 --- a/src/unity-editor.ts +++ b/src/unity-editor.ts @@ -1,3 +1,4 @@ +import * as os from 'os'; import * as fs from 'fs'; import * as path from 'path'; import { Logger } from './logging'; @@ -446,6 +447,23 @@ export class UnityEditor { return editorRootPath; } + /** + * Gets the path to the Unity Editor log directory. + * @returns The path to the Unity Editor logs directory. + */ + static GetEditorLogsDirectory() { + switch (process.platform) { + case 'darwin': + return path.join(os.homedir(), 'Library', 'Logs', 'Unity'); + case 'linux': + return path.join(os.homedir(), '.config', 'unity3d', 'Editor'); + case 'win32': + return path.join(process.env.LOCALAPPDATA || '', 'Unity', 'Editor'); + default: + throw new Error(`Unsupported platform: ${process.platform}`); + } + } + /** * Uninstall the Unity Editor. */