style: ssh文件操作log日志s输出信息
This commit is contained in:
@@ -80,7 +80,7 @@ func (s *SSHClientSFTP) CopyDirLocalToRemote(localDir, remoteDir string) error {
|
|||||||
} else {
|
} else {
|
||||||
// 如果是文件,则复制文件内容
|
// 如果是文件,则复制文件内容
|
||||||
if err := s.CopyFileLocalToRemote(localPath, remotePath); err != nil {
|
if err := s.CopyFileLocalToRemote(localPath, remotePath); err != nil {
|
||||||
logger.Errorf("CopyFileLocalToRemote failed to opening local file %s: => %s", localPath, err.Error())
|
logger.Errorf("CopyDirLocalToRemote failed to copying remote file %s: => %s", localPath, err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ func (s *SSHClientSFTP) CopyDirLocalToRemote(localDir, remoteDir string) error {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("CopyDirLocalToRemote failed to walking local directory: => %s", err.Error())
|
logger.Errorf("CopyDirLocalToRemote failed to walking remote directory: => %s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -134,6 +134,12 @@ func (s *SSHClientSFTP) CopyFileLocalToRemote(localPath, remotePath string) erro
|
|||||||
}
|
}
|
||||||
defer localFile.Close()
|
defer localFile.Close()
|
||||||
|
|
||||||
|
// 创建远程目录
|
||||||
|
// if err := s.Client.MkdirAll(filepath.Dir(remotePath)); err != nil {
|
||||||
|
// logger.Errorf("CopyFileLocalToRemote failed to creating remote directory %s: => %s", remotePath, err.Error())
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
|
||||||
// 创建远程文件
|
// 创建远程文件
|
||||||
remoteFile, err := s.Client.Create(remotePath)
|
remoteFile, err := s.Client.Create(remotePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ func (c *ConnSSH) RunCMD(cmd string) (string, error) {
|
|||||||
defer session.Close()
|
defer session.Close()
|
||||||
buf, err := session.CombinedOutput(cmd)
|
buf, err := session.CombinedOutput(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Infof("RunCMD failed run command: => %s", cmd)
|
||||||
logger.Errorf("RunCMD failed run command: => %s", err.Error())
|
logger.Errorf("RunCMD failed run command: => %s", err.Error())
|
||||||
}
|
}
|
||||||
c.LastResult = string(buf)
|
c.LastResult = string(buf)
|
||||||
|
|||||||
Reference in New Issue
Block a user