Skip to content

Commit

Permalink
log file added
Browse files Browse the repository at this point in the history
  • Loading branch information
logeshkrish committed Jan 12, 2021
1 parent 4d51e89 commit 5a062b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 10 additions & 3 deletions trace/listProcess/listproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ type Process struct {

func ListLog() error {
var args = []string{"-aeo", "uid,gid,pid,ppid,etimes,command"}
if err := cmd.ExecuteWithOut("ps", args, "./log/process_list.log"); err != nil {
if _, pidDirerr := cmd.ExecuteAsScript("cd ~/ && mkdir "+".sail", "sail directory creation failed"); pidDirerr != nil {
// return "", pidDirerr
}
if _, pidDirerr := cmd.ExecuteAsScript("cd ~/.sail && mkdir "+"log", "log directory creation failed"); pidDirerr != nil {
return pidDirerr
}
home := os.Getenv("HOME")
if err := cmd.ExecuteWithOut("ps", args, home+"/.sail/log/process_list.log"); err != nil {
return err
}
return nil
Expand All @@ -41,8 +48,8 @@ func ProcessList(slog *logrus.Entry) ([]Process, error) {
slog.Println("trace.startTrace Error : GetUser error %s", err.Error())
return processes, err
}

file, err := os.Open("./log/process_list.log")
home := os.Getenv("HOME")
file, err := os.Open(home + "/.sail/log/process_list.log")
if err != nil {
slog.Println("util/tools/process_list.go file error: %s", err.Error())
return processes, err
Expand Down
6 changes: 4 additions & 2 deletions trace/trace_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ func StartTracing_noreq(pid string, trace_time int, requestID string) (string, e
sCxt.Log.Printf("Pid: %s does not exist", pid)
return "", errors.New("Pid: " + pid + " does not exist")
}

if _, pidDirerr := cmd.ExecuteAsScript("cd ~/ && mkdir "+".sail", "sail directory creation failed"); pidDirerr != nil {
// return "", pidDirerr
}
if _, pidDirerr := cmd.ExecuteAsScript("cd ~/.sail && mkdir "+pid, "pid directory creation failed"); pidDirerr != nil {
return "", pidDirerr
// return "", pidDirerr
}

if e := startTrace.ENVList(pid, sCxt.Log); e != nil {
Expand Down

0 comments on commit 5a062b5

Please sign in to comment.