mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-24 07:46:39 +00:00
Merge pull request #2864 from balena-io/logs-to-device-logs
Add alias `device logs` for `logs` command
This commit is contained in:
commit
c1649dd828
@ -8,13 +8,13 @@ _balena() {
|
||||
local context state line curcontext="$curcontext"
|
||||
|
||||
# Valid top-level completions
|
||||
main_commands=( api-key app block build config deploy device devices env fleet internal join leave local login logout logs notes organization os preload push release settings ssh ssh-key support tag tunnel util version whoami )
|
||||
main_commands=( api-key app block build config deploy device devices env fleet internal join leave local login logout notes organization os preload push release settings ssh ssh-key support tag tunnel util version whoami )
|
||||
# Sub-completions
|
||||
api_key_cmds=( generate list revoke )
|
||||
app_cmds=( create )
|
||||
block_cmds=( create )
|
||||
config_cmds=( generate inject read reconfigure write )
|
||||
device_cmds=( deactivate detect identify init list local-mode move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet )
|
||||
device_cmds=( deactivate detect identify init list local-mode logs move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet )
|
||||
devices_cmds=( supported )
|
||||
env_cmds=( add list rename rm )
|
||||
fleet_cmds=( create list pin purge rename restart rm track-latest )
|
||||
|
@ -7,13 +7,13 @@ _balena_complete()
|
||||
local cur prev
|
||||
|
||||
# Valid top-level completions
|
||||
main_commands="api-key app block build config deploy device devices env fleet internal join leave local login logout logs notes organization os preload push release settings ssh ssh-key support tag tunnel util version whoami"
|
||||
main_commands="api-key app block build config deploy device devices env fleet internal join leave local login logout notes organization os preload push release settings ssh ssh-key support tag tunnel util version whoami"
|
||||
# Sub-completions
|
||||
api_key_cmds="generate list revoke"
|
||||
app_cmds="create"
|
||||
block_cmds="create"
|
||||
config_cmds="generate inject read reconfigure write"
|
||||
device_cmds="deactivate detect identify init list local-mode move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet"
|
||||
device_cmds="deactivate detect identify init list local-mode logs move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet"
|
||||
devices_cmds="supported"
|
||||
env_cmds="add list rename rm"
|
||||
fleet_cmds="create list pin purge rename restart rm track-latest"
|
||||
|
@ -202,6 +202,7 @@ are encouraged to regularly update the balena CLI to the latest version.
|
||||
- [device init](#device-init)
|
||||
- [device list](#device-list)
|
||||
- [device local-mode](#device-local-mode)
|
||||
- [device logs](#device-logs)
|
||||
- [device move](#device-move)
|
||||
- [device os-update](#device-os-update)
|
||||
- [device pin](#device-pin)
|
||||
@ -242,10 +243,6 @@ are encouraged to regularly update the balena CLI to the latest version.
|
||||
- [local configure](#local-configure)
|
||||
- [local flash](#local-flash)
|
||||
|
||||
- Logs
|
||||
|
||||
- [logs](#logs)
|
||||
|
||||
- Network
|
||||
|
||||
- [ssh](#ssh)
|
||||
@ -1515,6 +1512,70 @@ disable local mode
|
||||
|
||||
output boolean indicating local mode status
|
||||
|
||||
## device logs
|
||||
|
||||
### Aliases
|
||||
|
||||
- `logs`
|
||||
|
||||
|
||||
To use one of the aliases, replace `device logs` with the alias.
|
||||
|
||||
### Description
|
||||
|
||||
Show logs for a specific device.
|
||||
|
||||
By default, the command prints all log messages and exits.
|
||||
|
||||
To continuously stream output, and see new logs in real time, use the `--tail` option.
|
||||
|
||||
If an IP or .local address is passed to this command, logs are displayed from
|
||||
a local mode device with that address. Note that --tail is implied
|
||||
when this command is provided a local mode device.
|
||||
|
||||
Logs from a single service can be displayed with the --service flag. Just system logs
|
||||
can be shown with the --system flag. Note that these flags can be used together.
|
||||
|
||||
Note: --service and --system flags must come after the device parameter, as per examples.
|
||||
|
||||
Examples:
|
||||
|
||||
$ balena device logs 23c73a1
|
||||
$ balena device logs 23c73a1 --tail
|
||||
|
||||
$ balena device logs 192.168.0.31
|
||||
$ balena device logs 192.168.0.31 --service my-service
|
||||
$ balena device logs 192.168.0.31 --service my-service-1 --service my-service-2
|
||||
|
||||
$ balena device logs 23c73a1.local --system
|
||||
$ balena device logs 23c73a1.local --system --service my-service
|
||||
|
||||
### Arguments
|
||||
|
||||
#### DEVICE
|
||||
|
||||
device UUID, IP, or .local address
|
||||
|
||||
### Options
|
||||
|
||||
#### --max-retry MAX-RETRY
|
||||
|
||||
Maximum number of reconnection attempts on "connection lost" errors
|
||||
(use 0 to disable auto reconnection).
|
||||
|
||||
#### -t, --tail
|
||||
|
||||
continuously stream output
|
||||
|
||||
#### -s, --service SERVICE
|
||||
|
||||
Reject logs not originating from this service.
|
||||
This can be used in combination with --system or other --service flags.
|
||||
|
||||
#### -S, --system
|
||||
|
||||
Only show system logs. This can be used in combination with --service.
|
||||
|
||||
## device move
|
||||
|
||||
### Description
|
||||
@ -2572,65 +2633,6 @@ Check `balena util available-drives` for available options.
|
||||
|
||||
answer "yes" to all questions (non interactive use)
|
||||
|
||||
# Logs
|
||||
|
||||
## logs
|
||||
|
||||
### Description
|
||||
|
||||
Show logs for a specific device.
|
||||
|
||||
By default, the command prints all log messages and exits.
|
||||
|
||||
To continuously stream output, and see new logs in real time, use the `--tail` option.
|
||||
|
||||
If an IP or .local address is passed to this command, logs are displayed from
|
||||
a local mode device with that address. Note that --tail is implied
|
||||
when this command is provided a local mode device.
|
||||
|
||||
Logs from a single service can be displayed with the --service flag. Just system logs
|
||||
can be shown with the --system flag. Note that these flags can be used together.
|
||||
|
||||
Note: --service and --system flags must come after the device parameter, as per examples.
|
||||
|
||||
Examples:
|
||||
|
||||
$ balena logs 23c73a1
|
||||
$ balena logs 23c73a1 --tail
|
||||
|
||||
$ balena logs 192.168.0.31
|
||||
$ balena logs 192.168.0.31 --service my-service
|
||||
$ balena logs 192.168.0.31 --service my-service-1 --service my-service-2
|
||||
|
||||
$ balena logs 23c73a1.local --system
|
||||
$ balena logs 23c73a1.local --system --service my-service
|
||||
|
||||
### Arguments
|
||||
|
||||
#### DEVICE
|
||||
|
||||
device UUID, IP, or .local address
|
||||
|
||||
### Options
|
||||
|
||||
#### --max-retry MAX-RETRY
|
||||
|
||||
Maximum number of reconnection attempts on "connection lost" errors
|
||||
(use 0 to disable auto reconnection).
|
||||
|
||||
#### -t, --tail
|
||||
|
||||
continuously stream output
|
||||
|
||||
#### -s, --service SERVICE
|
||||
|
||||
Reject logs not originating from this service.
|
||||
This can be used in combination with --system or other --service flags.
|
||||
|
||||
#### -S, --system
|
||||
|
||||
Only show system logs. This can be used in combination with --service.
|
||||
|
||||
# Network
|
||||
|
||||
## ssh
|
||||
|
12
npm-shrinkwrap.json
generated
12
npm-shrinkwrap.json
generated
@ -3739,9 +3739,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.16.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.12.tgz",
|
||||
"integrity": "sha512-LfPFB0zOeCeCNQV3i+67rcoVvoN5n0NVuR2vLG0O5ySQMgchuZlC4lgz546ZOJyDtj5KIgOxy+lacOimfqZAIA==",
|
||||
"version": "20.16.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.13.tgz",
|
||||
"integrity": "sha512-GjQ7im10B0labo8ZGXDGROUl9k0BNyDgzfGpb4g/cl+4yYDWVKcozANF4FGr4/p0O/rAkQClM6Wiwkije++1Tg==",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.19.2"
|
||||
}
|
||||
@ -5475,9 +5475,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/balena-sdk/node_modules/@types/node": {
|
||||
"version": "18.19.56",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.56.tgz",
|
||||
"integrity": "sha512-4EMJlWwwGnVPflJAtM14p9eVSa6BOv5b92mCsh5zcM1UagNtEtrbbtaE6WE1tw2TabavatnwqXjlIpcAEuJJNg==",
|
||||
"version": "18.19.57",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.57.tgz",
|
||||
"integrity": "sha512-I2ioBd/IPrYDMv9UNR5NlPElOZ68QB7yY5V2EsLtSrTO0LM0PnCEFF9biLWHf5k+sIy4ohueCV9t4gk1AEdlVA==",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ import type { LogMessage } from 'balena-sdk';
|
||||
|
||||
const MAX_RETRY = 1000;
|
||||
|
||||
export default class LogsCmd extends Command {
|
||||
export default class DeviceLogsCmd extends Command {
|
||||
public static aliases = ['logs'];
|
||||
|
||||
public static description = stripIndent`
|
||||
Show device logs.
|
||||
|
||||
@ -42,15 +44,15 @@ export default class LogsCmd extends Command {
|
||||
Note: --service and --system flags must come after the device parameter, as per examples.
|
||||
`;
|
||||
public static examples = [
|
||||
'$ balena logs 23c73a1',
|
||||
'$ balena logs 23c73a1 --tail',
|
||||
'$ balena device logs 23c73a1',
|
||||
'$ balena device logs 23c73a1 --tail',
|
||||
'',
|
||||
'$ balena logs 192.168.0.31',
|
||||
'$ balena logs 192.168.0.31 --service my-service',
|
||||
'$ balena logs 192.168.0.31 --service my-service-1 --service my-service-2',
|
||||
'$ balena device logs 192.168.0.31',
|
||||
'$ balena device logs 192.168.0.31 --service my-service',
|
||||
'$ balena device logs 192.168.0.31 --service my-service-1 --service my-service-2',
|
||||
'',
|
||||
'$ balena logs 23c73a1.local --system',
|
||||
'$ balena logs 23c73a1.local --system --service my-service',
|
||||
'$ balena device logs 23c73a1.local --system',
|
||||
'$ balena device logs 23c73a1.local --system --service my-service',
|
||||
];
|
||||
|
||||
public static args = {
|
||||
@ -90,7 +92,7 @@ export default class LogsCmd extends Command {
|
||||
public static primary = true;
|
||||
|
||||
public async run() {
|
||||
const { args: params, flags: options } = await this.parse(LogsCmd);
|
||||
const { args: params, flags: options } = await this.parse(DeviceLogsCmd);
|
||||
|
||||
const balena = getBalenaSdk();
|
||||
const { serviceIdToName } = await import('../../utils/cloud');
|
@ -227,7 +227,6 @@ See: https://git.io/JRHUW#deprecation-policy`,
|
||||
readonly manuallySortedPrimaryCommands = [
|
||||
'login',
|
||||
'push',
|
||||
'logs',
|
||||
'ssh',
|
||||
'fleet',
|
||||
'device',
|
||||
|
@ -17,13 +17,13 @@
|
||||
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { BalenaAPIMock } from '../nock/balena-api-mock';
|
||||
import { cleanOutput, runCommand } from '../helpers';
|
||||
import { SupervisorMock } from '../nock/supervisor-mock';
|
||||
import { BalenaAPIMock } from '../../nock/balena-api-mock';
|
||||
import { cleanOutput, runCommand } from '../../helpers';
|
||||
import { SupervisorMock } from '../../nock/supervisor-mock';
|
||||
|
||||
const itS = process.env.BALENA_CLI_TEST_TYPE === 'standalone' ? it : it.skip;
|
||||
|
||||
describe('balena logs', function () {
|
||||
describe('balena device logs', function () {
|
||||
let api: BalenaAPIMock;
|
||||
let supervisor: SupervisorMock;
|
||||
|
||||
@ -47,7 +47,7 @@ describe('balena logs', function () {
|
||||
supervisor.expectGetLogs();
|
||||
supervisor.expectGetLogs();
|
||||
|
||||
const { err, out } = await runCommand('logs 1.2.3.4 --max-retry 1');
|
||||
const { err, out } = await runCommand('device logs 1.2.3.4 --max-retry 1');
|
||||
|
||||
const errLines = cleanOutput(err, true);
|
||||
const errMsg =
|
@ -28,7 +28,6 @@ $ balena [COMMAND] [OPTIONS]
|
||||
PRIMARY COMMANDS
|
||||
login login to balena
|
||||
push <applicationOrDevice> start a remote build on the balenaCloud build servers or a local mode device
|
||||
logs <device> show device logs
|
||||
ssh <applicationOrDevice> [service] SSH into the host or application container of a device
|
||||
app <name> display information about a single application
|
||||
device <uuid> show info about a single device
|
||||
@ -56,6 +55,7 @@ ADDITIONAL COMMANDS
|
||||
device identify <uuid> identify a device
|
||||
device init initialise a device with balenaOS
|
||||
device list list all devices
|
||||
device logs <device> show device logs
|
||||
device move <uuid(s)> move one or more devices to another application
|
||||
device os-update <uuid> start a Host OS update for a device
|
||||
device public-url <uuid> get or manage the public URL for a device
|
||||
|
@ -85,6 +85,9 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/local-mode.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/logs.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/move.js
|
||||
@ -190,9 +193,6 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/logout/index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/logs/index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/notes/index.js
|
||||
|
@ -85,6 +85,9 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/local-mode.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/logs.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/move.js
|
||||
@ -190,9 +193,6 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/logout/index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/logs/index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/notes/index.js
|
||||
|
@ -85,6 +85,9 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/local-mode.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/logs.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/move.js
|
||||
@ -190,9 +193,6 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/logout/index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/logs/index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/notes/index.js
|
||||
|
@ -85,6 +85,9 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/local-mode.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/logs.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/device/move.js
|
||||
@ -190,9 +193,6 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/logout/index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/logs/index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules/@oclif/core/package.json
|
||||
%2: build/commands/notes/index.js
|
||||
|
@ -85,6 +85,9 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules\@oclif\core\package.json
|
||||
%2: build\commands\device\local-mode.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules\@oclif\core\package.json
|
||||
%2: build\commands\device\logs.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules\@oclif\core\package.json
|
||||
%2: build\commands\device\move.js
|
||||
@ -190,9 +193,6 @@
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules\@oclif\core\package.json
|
||||
%2: build\commands\logout\index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules\@oclif\core\package.json
|
||||
%2: build\commands\logs\index.js
|
||||
> Warning Entry 'main' not found in %1
|
||||
%1: node_modules\@oclif\core\package.json
|
||||
%2: build\commands\notes\index.js
|
||||
|
Loading…
Reference in New Issue
Block a user