sf-debug-log 0.1.2 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -31
- package/lib/commands/debug/delete.d.ts +7 -10
- package/lib/commands/debug/delete.js +48 -48
- package/lib/commands/debug/delete.js.map +1 -1
- package/lib/commands/debug/retrieve.d.ts +8 -10
- package/lib/commands/debug/retrieve.js +58 -65
- package/lib/commands/debug/retrieve.js.map +1 -1
- package/lib/commands/debuglevel/list.d.ts +11 -0
- package/lib/commands/debuglevel/list.js +40 -0
- package/lib/commands/debuglevel/list.js.map +1 -0
- package/lib/commands/debuglevel/new.d.ts +5 -8
- package/lib/commands/debuglevel/new.js +41 -53
- package/lib/commands/debuglevel/new.js.map +1 -1
- package/lib/commands/trace/new.d.ts +8 -11
- package/lib/commands/trace/new.js +60 -84
- package/lib/commands/trace/new.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +46 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts +8 -10
- package/lib/utils.js +36 -40
- package/lib/utils.js.map +1 -1
- package/messages/debug.delete.md +7 -3
- package/messages/debug.retrieve.md +8 -0
- package/messages/debuglevel.list.md +19 -0
- package/messages/debuglevel.new.md +13 -1
- package/messages/trace.new.md +12 -0
- package/package.json +17 -12
- package/oclif.manifest.json +0 -199
package/README.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# sf-debug-log
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Salesforce CLI plugin to make managing debug logs easier.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
I built this because I found the official `sf` CLI was missing some commands I regularly need. For example, I wanted to put a specific user under debug and retrieve only their logs, delete logs more easily, or set a new debug level from the command line. This plugin adds those missing pieces and more to make debugging faster.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
* Create trace flags for any user in the org, selecting the debug level and time.
|
|
10
|
+
* List all debug levels in the org.
|
|
11
|
+
* Retrieve Apex logs for a specific user or all users in the org.
|
|
12
|
+
* Delete Apex logs for a specific user or all users in the org.
|
|
7
13
|
|
|
8
14
|
## Install
|
|
9
15
|
|
|
@@ -12,101 +18,119 @@ sf plugins install sf-debug-log
|
|
|
12
18
|
```
|
|
13
19
|
|
|
14
20
|
## Commands
|
|
15
|
-
|
|
16
21
|
<!-- commands -->
|
|
17
|
-
|
|
18
22
|
- [`sf trace new`](#sf-trace-new)
|
|
19
23
|
- [`sf debug retrieve`](#sf-debug-retrieve)
|
|
20
|
-
- [`sf debug delete`](#sf-
|
|
24
|
+
- [`sf debug delete`](#sf-debug-delete)
|
|
25
|
+
- [`sf debuglevel list`](#sf-debuglevel-list)
|
|
21
26
|
- [`sf debuglevel new`](#sf-debuglevel-new)
|
|
22
27
|
|
|
23
28
|
## `sf trace new`
|
|
24
29
|
|
|
30
|
+
Create a new trace flag.
|
|
31
|
+
|
|
25
32
|
```
|
|
26
33
|
USAGE
|
|
27
|
-
$ sf trace new -o <value> [-u <value>] [-t <value>]
|
|
34
|
+
$ sf trace new -o <value> -d <value> [-u <value>] [-t <value>] [-f]
|
|
28
35
|
|
|
29
36
|
FLAGS
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
37
|
+
-d, --debuglevel=<value> [default: SFDC_DevConsole] The debug level for the trace flag.
|
|
38
|
+
-f, --force Force the creation of a new trace flag, even if one already exists for the user.
|
|
39
|
+
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
40
|
+
-t, --time=<value> [default: 60] The number of minutes to trace.
|
|
41
|
+
-u, --user=<value> [default: current user] Username, Name, or ID of the user for whom you want to retrieve the logs.
|
|
33
42
|
|
|
34
43
|
GLOBAL FLAGS
|
|
35
44
|
--json Format output as json.
|
|
36
45
|
|
|
37
46
|
DESCRIPTION
|
|
38
|
-
Create a new trace flag.
|
|
39
|
-
|
|
40
47
|
This command is used to create a trace flag for a specific user in the Salesforce org.
|
|
41
48
|
|
|
42
49
|
EXAMPLES
|
|
43
|
-
sf trace new -o DeveloperEdition -u "Raffaele Preziosi" -t 10
|
|
50
|
+
sf trace new -o DeveloperEdition -u "Raffaele Preziosi" -t 10 -d "MyDebugLevel"
|
|
44
51
|
```
|
|
45
52
|
|
|
46
53
|
## `sf debug retrieve`
|
|
47
54
|
|
|
55
|
+
Retrieve Apex log files from the Salesforce platform.
|
|
56
|
+
|
|
48
57
|
```
|
|
49
58
|
USAGE
|
|
50
|
-
$
|
|
59
|
+
$ sf debug retrieve -o <value> [-u <value>] [-t <value>] [-d <value>] [-a]
|
|
51
60
|
|
|
52
61
|
FLAGS
|
|
62
|
+
-a, --all-users Retrieve log files for all users.
|
|
53
63
|
-d, --folder=<value> [default: .sfdx/tools/debug/logs] The folder where the retrieved log files will be stored.
|
|
54
64
|
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
55
|
-
-t, --time=<value>
|
|
56
|
-
-u, --user=<value> [default:
|
|
65
|
+
-t, --time=<value> The number of minutes to retrieve log files for.
|
|
66
|
+
-u, --user=<value> [default: current user] Username, Name, or ID of the user for whom you want to retrieve the logs.
|
|
57
67
|
|
|
58
68
|
GLOBAL FLAGS
|
|
59
69
|
--json Format output as json.
|
|
60
70
|
|
|
61
|
-
DESCRIPTION
|
|
62
|
-
Retrieve Apex log files from the Salesforce platform.
|
|
63
|
-
|
|
64
|
-
This command allows you to retrieve Apex log files from a Salesforce org.
|
|
65
|
-
|
|
66
71
|
EXAMPLES
|
|
67
72
|
sf debug retrieve -o DeveloperEdition -u "Raffaele Preziosi" -t 10
|
|
68
73
|
```
|
|
69
74
|
|
|
70
75
|
## `sf debug delete`
|
|
71
76
|
|
|
77
|
+
Delete Apex log files from a Salesforce org.
|
|
78
|
+
|
|
72
79
|
```
|
|
73
80
|
USAGE
|
|
74
|
-
$
|
|
81
|
+
$ sf debug delete -o <value> [--json] [-u <value>] [-t <value>] [-a]
|
|
75
82
|
|
|
76
83
|
FLAGS
|
|
77
|
-
-a, --all
|
|
84
|
+
-a, --all-users Delete log files for all users.
|
|
78
85
|
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
79
86
|
-t, --time=<value> The number of minutes to retrieve log files for.
|
|
80
|
-
-u, --user=<value> [default:
|
|
87
|
+
-u, --user=<value> [default: current user] Username, Name, or ID of the user for whom you want to retrieve the logs.
|
|
81
88
|
|
|
82
89
|
GLOBAL FLAGS
|
|
83
90
|
--json Format output as json.
|
|
84
91
|
|
|
85
|
-
DESCRIPTION
|
|
86
|
-
Delete Apex log files from a Salesforce org.
|
|
87
|
-
|
|
88
92
|
EXAMPLES
|
|
89
93
|
sf debug delete -o DeveloperEdition -u "Raffaele Preziosi" -t 10
|
|
90
94
|
```
|
|
91
95
|
|
|
96
|
+
## `sf debuglevel list`
|
|
97
|
+
|
|
98
|
+
List all DebugLevels in the org.
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
USAGE
|
|
102
|
+
$ sf debuglevel list -o <value>
|
|
103
|
+
|
|
104
|
+
FLAGS
|
|
105
|
+
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
106
|
+
|
|
107
|
+
GLOBAL FLAGS
|
|
108
|
+
--json Format output as json.
|
|
109
|
+
|
|
110
|
+
EXAMPLES
|
|
111
|
+
sf debuglevel list -o DeveloperEdition
|
|
112
|
+
```
|
|
113
|
+
|
|
92
114
|
## `sf debuglevel new`
|
|
93
115
|
|
|
116
|
+
Create a new DebugLevel.
|
|
117
|
+
|
|
94
118
|
```
|
|
95
119
|
USAGE
|
|
96
120
|
$ sf debuglevel new -o <value> [-n <value>]
|
|
97
121
|
|
|
98
122
|
FLAGS
|
|
99
|
-
-
|
|
100
|
-
-
|
|
123
|
+
-n, --name=<value> (required) The developer name of the new DebugLevel.
|
|
124
|
+
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
101
125
|
|
|
102
126
|
GLOBAL FLAGS
|
|
103
127
|
--json Format output as json.
|
|
104
128
|
|
|
105
129
|
DESCRIPTION
|
|
106
|
-
Create a new DebugLevel.
|
|
107
|
-
|
|
108
130
|
Create a new DebugLevel assigning level for each category.
|
|
109
131
|
|
|
110
132
|
EXAMPLES
|
|
111
133
|
sf debuglevel new -o DeveloperEdition -n "DebugLevel"
|
|
112
134
|
```
|
|
135
|
+
|
|
136
|
+
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
export
|
|
3
|
-
isSuccess: boolean;
|
|
4
|
-
error?: string;
|
|
5
|
-
};
|
|
6
|
-
export default class DebugDelete extends SfCommand<DebugDeleteResult> {
|
|
2
|
+
export default class DebugDelete extends SfCommand<void> {
|
|
7
3
|
static readonly summary: string;
|
|
8
4
|
static readonly description: string;
|
|
9
5
|
static readonly examples: string[];
|
|
10
6
|
static readonly flags: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
targetusername: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
time: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'all-users': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
12
|
};
|
|
16
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<void>;
|
|
17
14
|
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Messages } from '@salesforce/core';
|
|
3
|
+
import { getUserId, getLogs, deleteLogs } from '../../utils.js';
|
|
4
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
5
|
+
const messages = Messages.loadMessages('sf-debug-log', 'debug.delete');
|
|
6
|
+
export default class DebugDelete extends SfCommand {
|
|
7
|
+
static summary = messages.getMessage('summary');
|
|
8
|
+
static description = messages.getMessage('description');
|
|
9
|
+
static examples = messages.getMessages('examples');
|
|
10
|
+
static flags = {
|
|
11
|
+
'api-version': Flags.orgApiVersion({
|
|
12
|
+
summary: messages.getMessage('flags.api-version.summary'),
|
|
13
|
+
}),
|
|
14
|
+
targetusername: Flags.requiredOrg({
|
|
15
|
+
summary: messages.getMessage('flags.targetusername.summary'),
|
|
16
|
+
char: 'o',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
user: Flags.string({
|
|
20
|
+
summary: messages.getMessage('flags.user.summary'),
|
|
21
|
+
char: 'u',
|
|
22
|
+
}),
|
|
23
|
+
time: Flags.integer({
|
|
24
|
+
summary: messages.getMessage('flags.time.summary'),
|
|
25
|
+
char: 't',
|
|
26
|
+
}),
|
|
27
|
+
'all-users': Flags.boolean({
|
|
28
|
+
summary: messages.getMessage('flags.all-users.summary'),
|
|
29
|
+
char: 'a',
|
|
30
|
+
default: false,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
9
33
|
async run() {
|
|
10
34
|
const { flags } = await this.parse(DebugDelete);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
35
|
+
if (flags['all-users'] && flags.user) {
|
|
36
|
+
this.error('Cannot use --all-users and --user flags together');
|
|
37
|
+
}
|
|
38
|
+
const conn = flags.targetusername.getConnection(flags['api-version']);
|
|
39
|
+
const getLogsOptions = {};
|
|
40
|
+
if (!flags['all-users']) {
|
|
15
41
|
const user = flags.user ? flags.user : conn.getUsername();
|
|
16
|
-
const userId = await
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return { isSuccess: true };
|
|
42
|
+
const userId = await getUserId(conn, user);
|
|
43
|
+
if (!userId) {
|
|
44
|
+
this.error(`User ${user} not found`);
|
|
45
|
+
}
|
|
46
|
+
getLogsOptions.userId = userId;
|
|
22
47
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
isSuccess: false,
|
|
26
|
-
error: err instanceof Error ? err.message : String(err),
|
|
27
|
-
};
|
|
28
|
-
throw messages.createError('error.deleteLogs', [result.error]);
|
|
48
|
+
if (flags.time) {
|
|
49
|
+
getLogsOptions.timeLimit = flags.time;
|
|
29
50
|
}
|
|
51
|
+
const logs = await getLogs(conn, getLogsOptions);
|
|
52
|
+
await deleteLogs(conn, logs);
|
|
53
|
+
this.log(`deleted\t${logs.length}`);
|
|
30
54
|
}
|
|
31
55
|
}
|
|
32
|
-
DebugDelete.summary = messages.getMessage('summary');
|
|
33
|
-
DebugDelete.description = messages.getMessage('description');
|
|
34
|
-
DebugDelete.examples = messages.getMessages('examples');
|
|
35
|
-
DebugDelete.flags = {
|
|
36
|
-
targetusername: sf_plugins_core_1.Flags.requiredOrg({
|
|
37
|
-
summary: messages.getMessage('flags.targetusername.summary'),
|
|
38
|
-
char: 'o',
|
|
39
|
-
required: true,
|
|
40
|
-
}),
|
|
41
|
-
user: sf_plugins_core_1.Flags.string({
|
|
42
|
-
summary: messages.getMessage('flags.user.summary'),
|
|
43
|
-
char: 'u',
|
|
44
|
-
}),
|
|
45
|
-
time: sf_plugins_core_1.Flags.integer({
|
|
46
|
-
summary: messages.getMessage('flags.time.summary'),
|
|
47
|
-
char: 't',
|
|
48
|
-
}),
|
|
49
|
-
all: sf_plugins_core_1.Flags.boolean({
|
|
50
|
-
summary: messages.getMessage('flags.all.summary'),
|
|
51
|
-
char: 'a',
|
|
52
|
-
default: false
|
|
53
|
-
})
|
|
54
|
-
};
|
|
55
|
-
exports.default = DebugDelete;
|
|
56
56
|
//# sourceMappingURL=delete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/debug/delete.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/debug/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEhE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;AAIvE,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAe;IAC/C,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC;YACjC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC;SAC1D,CAAC;QACF,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC;YAChC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;YAC5D,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YACjB,OAAO,EAAE,QAAQ,CAAC,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AAC,IAAI,CAAC;QACxC,CAAC;QAED,MAAM,IAAI,GAAc,MAAM,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC5D,MAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
export
|
|
3
|
-
isSuccess: boolean;
|
|
4
|
-
error?: string;
|
|
5
|
-
};
|
|
6
|
-
export default class Retrieve extends SfCommand<RetrieveResult> {
|
|
2
|
+
export default class Retrieve extends SfCommand<void> {
|
|
7
3
|
static readonly summary: string;
|
|
8
4
|
static readonly description: string;
|
|
9
5
|
static readonly examples: string[];
|
|
10
6
|
static readonly flags: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
targetusername: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
time: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
folder: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'all-users': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
13
|
};
|
|
16
|
-
run(): Promise<
|
|
14
|
+
run(): Promise<void>;
|
|
17
15
|
}
|
|
@@ -1,81 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
3
|
+
import { Messages } from '@salesforce/core';
|
|
4
|
+
import { getUserId, createFile, getLogs } from '../../utils.js';
|
|
5
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
6
|
+
const messages = Messages.loadMessages('sf-debug-log', 'debug.retrieve');
|
|
7
|
+
export default class Retrieve extends SfCommand {
|
|
8
|
+
static summary = messages.getMessage('summary');
|
|
9
|
+
static description = messages.getMessage('description');
|
|
10
|
+
static examples = messages.getMessages('examples');
|
|
11
|
+
static flags = {
|
|
12
|
+
'api-version': Flags.orgApiVersion({
|
|
13
|
+
summary: messages.getMessage('flags.api-version.summary'),
|
|
14
|
+
}),
|
|
15
|
+
targetusername: Flags.requiredOrg({
|
|
16
|
+
summary: messages.getMessage('flags.targetusername.summary'),
|
|
17
|
+
char: 'o',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
user: Flags.string({
|
|
21
|
+
summary: messages.getMessage('flags.user.summary'),
|
|
22
|
+
char: 'u',
|
|
23
|
+
}),
|
|
24
|
+
time: Flags.integer({
|
|
25
|
+
summary: messages.getMessage('flags.time.summary'),
|
|
26
|
+
char: 't',
|
|
27
|
+
}),
|
|
28
|
+
folder: Flags.directory({
|
|
29
|
+
summary: messages.getMessage('flags.folder.summary'),
|
|
30
|
+
char: 'd',
|
|
31
|
+
default: '.sfdx/tools/debug/logs',
|
|
32
|
+
}),
|
|
33
|
+
'all-users': Flags.boolean({
|
|
34
|
+
summary: messages.getMessage('flags.all-users.summary'),
|
|
35
|
+
char: 'a',
|
|
36
|
+
default: false,
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
14
39
|
async run() {
|
|
15
40
|
const { flags } = await this.parse(Retrieve);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
41
|
+
if (flags['all-users'] && flags.user) {
|
|
42
|
+
this.error('Cannot use --all-users and --user flags together');
|
|
43
|
+
}
|
|
44
|
+
const conn = flags.targetusername.getConnection(flags['api-version']);
|
|
45
|
+
const getLogsOptions = {};
|
|
46
|
+
if (!flags['all-users']) {
|
|
47
|
+
// Default to the current user if no user is specified
|
|
20
48
|
const user = flags.user ? flags.user : conn.getUsername();
|
|
21
|
-
const userId = await
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
49
|
+
const userId = await getUserId(conn, user);
|
|
50
|
+
if (!userId) {
|
|
51
|
+
this.error(`User ${user} not found`);
|
|
52
|
+
}
|
|
53
|
+
getLogsOptions.userId = userId;
|
|
26
54
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
isSuccess: false,
|
|
30
|
-
error: err instanceof Error ? err.message : String(err),
|
|
31
|
-
};
|
|
32
|
-
throw messages.createError('error.saveLogs', [result.error]);
|
|
55
|
+
if (flags.time) {
|
|
56
|
+
getLogsOptions.timeLimit = flags.time;
|
|
33
57
|
}
|
|
58
|
+
const logs = await getLogs(conn, getLogsOptions);
|
|
59
|
+
await saveLogs(conn, logs, flags.folder);
|
|
60
|
+
this.log(`saved\t${logs.length}`);
|
|
34
61
|
}
|
|
35
62
|
}
|
|
36
|
-
Retrieve.summary = messages.getMessage('summary');
|
|
37
|
-
Retrieve.description = messages.getMessage('description');
|
|
38
|
-
Retrieve.examples = messages.getMessages('examples');
|
|
39
|
-
Retrieve.flags = {
|
|
40
|
-
targetusername: sf_plugins_core_1.Flags.requiredOrg({
|
|
41
|
-
summary: messages.getMessage('flags.targetusername.summary'),
|
|
42
|
-
char: 'o',
|
|
43
|
-
required: true,
|
|
44
|
-
}),
|
|
45
|
-
user: sf_plugins_core_1.Flags.string({
|
|
46
|
-
summary: messages.getMessage('flags.user.summary'),
|
|
47
|
-
char: 'u',
|
|
48
|
-
}),
|
|
49
|
-
time: sf_plugins_core_1.Flags.integer({
|
|
50
|
-
summary: messages.getMessage('flags.time.summary'),
|
|
51
|
-
char: 't',
|
|
52
|
-
default: 60,
|
|
53
|
-
}),
|
|
54
|
-
folder: sf_plugins_core_1.Flags.directory({
|
|
55
|
-
summary: messages.getMessage('flags.folder.summary'),
|
|
56
|
-
char: 'd',
|
|
57
|
-
default: '.sfdx/tools/debug/logs',
|
|
58
|
-
}),
|
|
59
|
-
};
|
|
60
|
-
exports.default = Retrieve;
|
|
61
63
|
async function saveLogs(conn, logs, directory) {
|
|
62
64
|
// Use Promise.all to parallelize the download and save operations
|
|
63
65
|
await Promise.all(logs.map(async (log) => {
|
|
64
66
|
const url = `${conn.instanceUrl}/apexdebug/traceDownload.apexp?id=${log.Id}`;
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
const hours = date.getHours();
|
|
68
|
-
const minutes = date.getMinutes();
|
|
69
|
-
const seconds = date.getSeconds();
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
|
|
71
|
-
const fileName = `(${hours}-${minutes}-${seconds}) ${log.DurationMilliseconds}ms ${log.Request} ${log.Operation} ${log.Status}.log`;
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
73
|
-
const sanitizedFileName = (0, sanitize_filename_1.default)(fileName);
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
|
|
75
|
-
const filePath = `${directory}/${log.LogUser.Name}/${sanitizedFileName}`;
|
|
67
|
+
const fileName = `${log.Id}.log`;
|
|
68
|
+
const filePath = path.join(directory, fileName);
|
|
76
69
|
try {
|
|
77
70
|
const body = await conn.request(url);
|
|
78
|
-
await
|
|
71
|
+
await createFile(filePath, body);
|
|
79
72
|
}
|
|
80
73
|
catch (err) {
|
|
81
74
|
throw new Error('Error saving debug logs');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieve.js","sourceRoot":"","sources":["../../../src/commands/debug/retrieve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retrieve.js","sourceRoot":"","sources":["../../../src/commands/debug/retrieve.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAc,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEhE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAIzE,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,SAAe;IAC5C,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC;YACjC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC;SAC1D,CAAC;QACF,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC;YAChC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;YAC5D,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YACjB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;YAClD,IAAI,EAAE,GAAG;SACV,CA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CAAC,MAAM,GAAG,MAAM,CAAC;QACjC,CAAC;QAED,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACf,cAAc,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;QACxC,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACjD,MAAM,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACpC,CAAC;;AAGH,KAAK,UAAU,QAAQ,CAAC,IAAgB,EAAE,IAAe,EAAE,SAAiB;IAC1E,kEAAkE;IAClE,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACrB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,WAAW,qCAAqC,GAAG,CAAC,EAAE,EAAE,CAAC;QAC7E,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,EAAE,MAAM,CAAC;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACrC,MAAM,UAAU,CAAC,QAAQ,EAAE,IAAc,CAAC,CAAC;QAC7C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export default class List extends SfCommand<void> {
|
|
3
|
+
static readonly summary: string;
|
|
4
|
+
static readonly description: string;
|
|
5
|
+
static readonly examples: string[];
|
|
6
|
+
static readonly flags: {
|
|
7
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
targetusername: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Messages } from '@salesforce/core';
|
|
3
|
+
import { getDebugLevels } from '../../utils.js';
|
|
4
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
5
|
+
const messages = Messages.loadMessages('sf-debug-log', 'debuglevel.list');
|
|
6
|
+
export default class List extends SfCommand {
|
|
7
|
+
static summary = messages.getMessage('summary');
|
|
8
|
+
static description = messages.getMessage('description');
|
|
9
|
+
static examples = messages.getMessages('examples');
|
|
10
|
+
static flags = {
|
|
11
|
+
'api-version': Flags.orgApiVersion({
|
|
12
|
+
summary: messages.getMessage('flags.api-version.summary'),
|
|
13
|
+
}),
|
|
14
|
+
targetusername: Flags.requiredOrg({
|
|
15
|
+
summary: messages.getMessage('flags.targetusername.summary'),
|
|
16
|
+
char: 'o',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
const { flags } = await this.parse(List);
|
|
22
|
+
const conn = flags.targetusername.getConnection(flags['api-version']);
|
|
23
|
+
const debugLevels = await getDebugLevels(conn);
|
|
24
|
+
const data = debugLevels.map((level) => ({
|
|
25
|
+
DeveloperName: level.DeveloperName,
|
|
26
|
+
Workflow: level.Workflow,
|
|
27
|
+
Validation: level.Validation,
|
|
28
|
+
Callout: level.Callout,
|
|
29
|
+
ApexCode: level.ApexCode,
|
|
30
|
+
ApexProfiling: level.ApexProfiling,
|
|
31
|
+
Visualforce: level.Visualforce,
|
|
32
|
+
System: level.System,
|
|
33
|
+
Database: level.Database,
|
|
34
|
+
Wave: level.Wave,
|
|
35
|
+
Nba: level.Nba
|
|
36
|
+
}));
|
|
37
|
+
this.table({ data });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/debuglevel/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAc,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAE1E,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,SAAe;IACxC,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC;YACjC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,2BAA2B,CAAC;SAC1D,CAAC;QACF,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC;YAChC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;YAC5D,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,IAAI,GAAe,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QAClF,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACvC,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,GAAG,EAAE,KAAK,CAAC,GAAG;SACf,CAAC,CAAC,CAAC;QACJ,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACvB,CAAC"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
export
|
|
3
|
-
isSuccess: boolean;
|
|
4
|
-
error?: string;
|
|
5
|
-
};
|
|
6
|
-
export default class DebuglevelNew extends SfCommand<DebuglevelNewResult> {
|
|
2
|
+
export default class DebuglevelNew extends SfCommand<void> {
|
|
7
3
|
static readonly summary: string;
|
|
8
4
|
static readonly description: string;
|
|
9
5
|
static readonly examples: string[];
|
|
10
6
|
static readonly flags: {
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
targetusername: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
developername: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
10
|
};
|
|
14
|
-
run(): Promise<
|
|
11
|
+
run(): Promise<void>;
|
|
15
12
|
private createDebugLevelRecord;
|
|
16
13
|
private selectDebugLevel;
|
|
17
14
|
}
|