(ctx *gin.Context, req dto.SearchSSHLog)
| 726 | } |
| 727 | |
| 728 | func (u *SSHService) ExportLog(ctx *gin.Context, req dto.SearchSSHLog) (string, error) { |
| 729 | _, logs, err := u.LoadLog(ctx, req) |
| 730 | if err != nil { |
| 731 | return "", err |
| 732 | } |
| 733 | if len(logs) == 0 { |
| 734 | return "", buserr.New("ErrRecordNotFound") |
| 735 | } |
| 736 | tmpFileName := path.Join(global.Dir.TmpDir, "export/ssh-log", fmt.Sprintf("1panel-ssh-log-%s.csv", time.Now().Format(constant.DateTimeSlimLayout))) |
| 737 | if _, err := os.Stat(path.Dir(tmpFileName)); err != nil { |
| 738 | _ = os.MkdirAll(path.Dir(tmpFileName), constant.DirPerm) |
| 739 | } |
| 740 | if err := csvexport.ExportSSHLogs(tmpFileName, logs); err != nil { |
| 741 | return "", err |
| 742 | } |
| 743 | return tmpFileName, nil |
| 744 | } |
| 745 | |
| 746 | func (u *SSHService) LoadSSHFile(name string) (string, error) { |
| 747 | var fileName string |
nothing calls this directly
no test coverage detected