MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / ExportLog

Method ExportLog

agent/app/service/ssh.go:728–744  ·  view source on GitHub ↗
(ctx *gin.Context, req dto.SearchSSHLog)

Source from the content-addressed store, hash-verified

726}
727
728func (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
746func (u *SSHService) LoadSSHFile(name string) (string, error) {
747 var fileName string

Callers

nothing calls this directly

Calls 5

LoadLogMethod · 0.95
MkdirAllMethod · 0.80
ExportSSHLogsMethod · 0.80
FormatMethod · 0.45
StatMethod · 0.45

Tested by

no test coverage detected