forked from ForceCLI/force
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
52 lines (44 loc) · 883 Bytes
/
log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
)
var cmdLog = &Command{
Run: getLog,
Usage: "log",
Short: "Fetch debug logs",
Long: `
Fetch debug logs
Examples:
force log [list]
force log <id>
force log delete <id>
`,
}
func init() {
}
func getLog(cmd *Command, args []string) {
force, _ := ActiveForce()
if len(args) == 0 || args[0] == "list" {
records, err := force.QueryLogs()
if err != nil {
ErrorAndExit(err.Error())
}
DisplayForceRecords(records)
} else if args[0] == "delete" {
if len(args) != 2 {
ErrorAndExit("You need to provide the id of a debug log to delete.")
}
err := force.DeleteToolingRecord("ApexLog", args[1])
if err != nil {
ErrorAndExit(err.Error())
}
fmt.Println("Debug log deleted")
} else {
logId := args[0]
log, err := force.RetrieveLog(logId)
if err != nil {
ErrorAndExit(err.Error())
}
fmt.Println(log)
}
}