sf-debug-log 0.1.1 → 0.2.0
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 +87 -21
- 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 +56 -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 +38 -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 +39 -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 +58 -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 +37 -41
- package/lib/utils.js.map +1 -1
- package/messages/debug.delete.md +7 -3
- package/messages/debug.retrieve.md +4 -0
- package/messages/debuglevel.list.md +15 -0
- package/messages/debuglevel.new.md +13 -1
- package/messages/trace.new.md +8 -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,30 +18,30 @@ 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)
|
|
24
|
+
- [`sf debug delete`](#sf-debug-delete)
|
|
25
|
+
- [`sf debuglevel list`](#sf-debuglevel-list)
|
|
20
26
|
- [`sf debuglevel new`](#sf-debuglevel-new)
|
|
21
27
|
|
|
22
28
|
## `sf trace new`
|
|
23
29
|
|
|
30
|
+
Create a new trace flag.
|
|
31
|
+
|
|
24
32
|
```
|
|
25
33
|
USAGE
|
|
26
34
|
$ sf trace new -o <value> [-u <value>] [-t <value>]
|
|
27
35
|
|
|
28
36
|
FLAGS
|
|
29
|
-
-o, --targetusername=<value>
|
|
30
|
-
-t, --time=<value>
|
|
31
|
-
-u, --name=<value>
|
|
37
|
+
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
38
|
+
-t, --time=<value> [default: 60] The number of minutes to trace.
|
|
39
|
+
-u, --name=<value> Username, Name, or ID of the user for whom you want to retrieve the logs.
|
|
32
40
|
|
|
33
41
|
GLOBAL FLAGS
|
|
34
42
|
--json Format output as json.
|
|
35
43
|
|
|
36
44
|
DESCRIPTION
|
|
37
|
-
Create a new trace flag.
|
|
38
|
-
|
|
39
45
|
This command is used to create a trace flag for a specific user in the Salesforce org.
|
|
40
46
|
|
|
41
47
|
EXAMPLES
|
|
@@ -44,46 +50,106 @@ EXAMPLES
|
|
|
44
50
|
|
|
45
51
|
## `sf debug retrieve`
|
|
46
52
|
|
|
53
|
+
Retrieve Apex log files from the Salesforce platform.
|
|
54
|
+
|
|
47
55
|
```
|
|
48
56
|
USAGE
|
|
49
|
-
$
|
|
57
|
+
$ sf debug retrieve -o <value> [-u <value>] [-t <value>] [-d <value>] [-a]
|
|
50
58
|
|
|
51
59
|
FLAGS
|
|
60
|
+
-a, --all-users Retrieve log files for all users.
|
|
52
61
|
-d, --folder=<value> [default: .sfdx/tools/debug/logs] The folder where the retrieved log files will be stored.
|
|
53
62
|
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
54
|
-
-t, --time=<value>
|
|
55
|
-
-u, --user=<value>
|
|
63
|
+
-t, --time=<value> The number of minutes to retrieve log files for.
|
|
64
|
+
-u, --user=<value> Username, Name, or ID of the user for whom you want to retrieve the logs.
|
|
56
65
|
|
|
57
66
|
GLOBAL FLAGS
|
|
58
67
|
--json Format output as json.
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
EXAMPLES
|
|
70
|
+
sf debug retrieve -o DeveloperEdition -u "Raffaele Preziosi" -t 10
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## `sf debug delete`
|
|
74
|
+
|
|
75
|
+
Delete Apex log files from a Salesforce org.
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
USAGE
|
|
79
|
+
$ sf debug delete -o <value> [--json] [-u <value>] [-t <value>] [-a]
|
|
80
|
+
|
|
81
|
+
FLAGS
|
|
82
|
+
-a, --all-users Delete log files for all users.
|
|
83
|
+
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
84
|
+
-t, --time=<value> The number of minutes to retrieve log files for.
|
|
85
|
+
-u, --user=<value> Username, Name, or ID of the user for whom you want to delete the logs.
|
|
62
86
|
|
|
63
|
-
|
|
87
|
+
GLOBAL FLAGS
|
|
88
|
+
--json Format output as json.
|
|
64
89
|
|
|
65
90
|
EXAMPLES
|
|
66
|
-
sf debug
|
|
91
|
+
sf debug delete -o DeveloperEdition -u "Raffaele Preziosi" -t 10
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## `sf debuglevel list`
|
|
95
|
+
|
|
96
|
+
List all DebugLevels in the org.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
USAGE
|
|
100
|
+
$ sf debuglevel list -o <value>
|
|
101
|
+
|
|
102
|
+
FLAGS
|
|
103
|
+
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
104
|
+
|
|
105
|
+
GLOBAL FLAGS
|
|
106
|
+
--json Format output as json.
|
|
107
|
+
|
|
108
|
+
EXAMPLES
|
|
109
|
+
sf debuglevel list -o DeveloperEdition
|
|
67
110
|
```
|
|
68
111
|
|
|
69
112
|
## `sf debuglevel new`
|
|
70
113
|
|
|
114
|
+
Create a new DebugLevel.
|
|
115
|
+
|
|
71
116
|
```
|
|
72
117
|
USAGE
|
|
73
118
|
$ sf debuglevel new -o <value> [-n <value>]
|
|
74
119
|
|
|
75
120
|
FLAGS
|
|
76
|
-
-
|
|
77
|
-
-
|
|
121
|
+
-n, --name=<value> (required) The developer name of the new DebugLevel.
|
|
122
|
+
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
78
123
|
|
|
79
124
|
GLOBAL FLAGS
|
|
80
125
|
--json Format output as json.
|
|
81
126
|
|
|
82
127
|
DESCRIPTION
|
|
83
|
-
Create a new DebugLevel.
|
|
84
|
-
|
|
85
128
|
Create a new DebugLevel assigning level for each category.
|
|
86
129
|
|
|
87
130
|
EXAMPLES
|
|
88
131
|
sf debuglevel new -o DeveloperEdition -n "DebugLevel"
|
|
89
132
|
```
|
|
133
|
+
|
|
134
|
+
## `sf trace new`
|
|
135
|
+
|
|
136
|
+
Create a new trace flag.
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
USAGE
|
|
140
|
+
$ sf trace new -o <value> [-u <value>] [-t <value>]
|
|
141
|
+
|
|
142
|
+
FLAGS
|
|
143
|
+
-o, --targetusername=<value> (required) Username or alias of the target Salesforce org.
|
|
144
|
+
-t, --time=<value> [default: 60] The number of minutes to trace.
|
|
145
|
+
-u, --name=<value> Username, Name, or ID of the user for whom you want to retrieve the logs.
|
|
146
|
+
|
|
147
|
+
GLOBAL FLAGS
|
|
148
|
+
--json Format output as json.
|
|
149
|
+
|
|
150
|
+
DESCRIPTION
|
|
151
|
+
This command is used to create a trace flag for a specific user in the Salesforce org.
|
|
152
|
+
|
|
153
|
+
EXAMPLES
|
|
154
|
+
sf trace new -o DeveloperEdition -u "Raffaele Preziosi" -t 10
|
|
155
|
+
```
|
|
@@ -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,I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KAAK,CAAC,IAAI,EAAE,CAAC;YACf,cAAc,CAAC,SAAS,GAAG,KAAK,CAAC,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,72 @@
|
|
|
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
|
+
targetusername: Flags.requiredOrg({
|
|
14
|
+
summary: messages.getMessage('flags.targetusername.summary'),
|
|
15
|
+
char: 'o',
|
|
16
|
+
required: true,
|
|
17
|
+
}),
|
|
18
|
+
user: Flags.string({
|
|
19
|
+
summary: messages.getMessage('flags.user.summary'),
|
|
20
|
+
char: 'u',
|
|
21
|
+
}),
|
|
22
|
+
time: Flags.integer({
|
|
23
|
+
summary: messages.getMessage('flags.time.summary'),
|
|
24
|
+
char: 't',
|
|
25
|
+
}),
|
|
26
|
+
folder: Flags.directory({
|
|
27
|
+
summary: messages.getMessage('flags.folder.summary'),
|
|
28
|
+
char: 'd',
|
|
29
|
+
default: '.sfdx/tools/debug/logs',
|
|
30
|
+
}),
|
|
31
|
+
'all-users': Flags.boolean({
|
|
32
|
+
summary: messages.getMessage('flags.all-users.summary'),
|
|
33
|
+
char: 'a',
|
|
34
|
+
default: false,
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
14
37
|
async run() {
|
|
15
38
|
const { flags } = await this.parse(Retrieve);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
39
|
+
if (flags['all-users'] && flags.user) {
|
|
40
|
+
this.error('Cannot use --all-users and --user flags together');
|
|
41
|
+
}
|
|
42
|
+
const conn = flags.targetusername.getConnection(flags['api-version']);
|
|
43
|
+
const getLogsOptions = {};
|
|
44
|
+
if (!flags['all-users']) {
|
|
45
|
+
// Default to the current user if no user is specified
|
|
20
46
|
const user = flags.user ? flags.user : conn.getUsername();
|
|
21
|
-
const userId = await
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
47
|
+
const userId = await getUserId(conn, user);
|
|
48
|
+
if (!userId) {
|
|
49
|
+
this.error(`User ${user} not found`);
|
|
50
|
+
}
|
|
51
|
+
getLogsOptions.userId = userId;
|
|
26
52
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
isSuccess: false,
|
|
30
|
-
error: err instanceof Error ? err.message : String(err),
|
|
31
|
-
};
|
|
32
|
-
throw messages.createError('error.saveLogs', [result.error]);
|
|
53
|
+
if (flags.time) {
|
|
54
|
+
getLogsOptions.timeLimit = flags.time;
|
|
33
55
|
}
|
|
56
|
+
const logs = await getLogs(conn, getLogsOptions);
|
|
57
|
+
await saveLogs(conn, logs, flags.folder);
|
|
58
|
+
this.log(`saved\t${logs.length}`);
|
|
34
59
|
}
|
|
35
60
|
}
|
|
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
61
|
async function saveLogs(conn, logs, directory) {
|
|
62
62
|
// Use Promise.all to parallelize the download and save operations
|
|
63
63
|
await Promise.all(logs.map(async (log) => {
|
|
64
64
|
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}`;
|
|
65
|
+
const fileName = `${log.Id}.log`;
|
|
66
|
+
const filePath = path.join(directory, fileName);
|
|
76
67
|
try {
|
|
77
68
|
const body = await conn.request(url);
|
|
78
|
-
await
|
|
69
|
+
await createFile(filePath, body);
|
|
79
70
|
}
|
|
80
71
|
catch (err) {
|
|
81
72
|
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,EAAE;QACpC,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,CAAC;QACF,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC;YAClB,OAAO,E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,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,38 @@
|
|
|
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
|
+
targetusername: Flags.requiredOrg({
|
|
13
|
+
summary: messages.getMessage('flags.targetusername.summary'),
|
|
14
|
+
char: 'o',
|
|
15
|
+
required: true,
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
async run() {
|
|
19
|
+
const { flags } = await this.parse(List);
|
|
20
|
+
const conn = flags.targetusername.getConnection(flags['api-version']);
|
|
21
|
+
const debugLevels = await getDebugLevels(conn);
|
|
22
|
+
const data = debugLevels.map((level) => ({
|
|
23
|
+
DeveloperName: level.DeveloperName,
|
|
24
|
+
Workflow: level.Workflow,
|
|
25
|
+
Validation: level.Validation,
|
|
26
|
+
Callout: level.Callout,
|
|
27
|
+
ApexCode: level.ApexCode,
|
|
28
|
+
ApexProfiling: level.ApexProfiling,
|
|
29
|
+
Visualforce: level.Visualforce,
|
|
30
|
+
System: level.System,
|
|
31
|
+
Database: level.Database,
|
|
32
|
+
Wave: level.Wave,
|
|
33
|
+
Nba: level.Nba
|
|
34
|
+
}));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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
|
}
|