mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-25 00:50:31 +00:00
transfer logs: add error field
Fixes #1638 Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
6c94173ca1
commit
9c775e2213
2 changed files with 9 additions and 4 deletions
|
@ -352,6 +352,9 @@ func (t *BaseTransfer) checkUploadOutsideHomeDir(err error) int {
|
|||
if err == nil {
|
||||
return 0
|
||||
}
|
||||
if t.ErrTransfer == nil {
|
||||
t.ErrTransfer = err
|
||||
}
|
||||
if Config.TempPath == "" {
|
||||
return 0
|
||||
}
|
||||
|
@ -410,7 +413,8 @@ func (t *BaseTransfer) Close() error {
|
|||
var uploadFileSize int64
|
||||
if t.transferType == TransferDownload {
|
||||
logger.TransferLog(downloadLogSender, t.fsPath, elapsed, t.BytesSent.Load(), t.Connection.User.Username,
|
||||
t.Connection.ID, t.Connection.protocol, t.Connection.localAddr, t.Connection.remoteAddr, t.ftpMode)
|
||||
t.Connection.ID, t.Connection.protocol, t.Connection.localAddr, t.Connection.remoteAddr, t.ftpMode,
|
||||
t.ErrTransfer)
|
||||
ExecuteActionNotification(t.Connection, operationDownload, t.fsPath, t.requestPath, "", "", "", //nolint:errcheck
|
||||
t.BytesSent.Load(), t.ErrTransfer, elapsed, t.metadata)
|
||||
} else {
|
||||
|
@ -431,7 +435,8 @@ func (t *BaseTransfer) Close() error {
|
|||
t.updateQuota(numFiles, uploadFileSize)
|
||||
t.updateTimes()
|
||||
logger.TransferLog(uploadLogSender, t.fsPath, elapsed, t.BytesReceived.Load(), t.Connection.User.Username,
|
||||
t.Connection.ID, t.Connection.protocol, t.Connection.localAddr, t.Connection.remoteAddr, t.ftpMode)
|
||||
t.Connection.ID, t.Connection.protocol, t.Connection.localAddr, t.Connection.remoteAddr, t.ftpMode,
|
||||
t.ErrTransfer)
|
||||
}
|
||||
if t.ErrTransfer != nil {
|
||||
t.Connection.Log(logger.LevelError, "transfer error: %v, path: %q", t.ErrTransfer, t.fsPath)
|
||||
|
|
|
@ -203,7 +203,7 @@ func ErrorToConsole(format string, v ...any) {
|
|||
|
||||
// TransferLog logs uploads or downloads
|
||||
func TransferLog(operation, path string, elapsed int64, size int64, user, connectionID, protocol, localAddr,
|
||||
remoteAddr, ftpMode string,
|
||||
remoteAddr, ftpMode string, err error,
|
||||
) {
|
||||
ev := logger.Info().
|
||||
Timestamp().
|
||||
|
@ -219,7 +219,7 @@ func TransferLog(operation, path string, elapsed int64, size int64, user, connec
|
|||
if ftpMode != "" {
|
||||
ev.Str("ftp_mode", ftpMode)
|
||||
}
|
||||
ev.Send()
|
||||
ev.AnErr("error", err).Send()
|
||||
}
|
||||
|
||||
// CommandLog logs an SFTP/SCP/SSH command
|
||||
|
|
Loading…
Reference in a new issue