diff --git a/common/connection.go b/common/connection.go index 566725ba..a1a4fbf8 100644 --- a/common/connection.go +++ b/common/connection.go @@ -259,7 +259,7 @@ func (c *BaseConnection) CreateDir(virtualPath string) error { return err } if err := fs.Mkdir(fsPath); err != nil { - c.Log(logger.LevelWarn, "error creating dir: %#v error: %+v", fsPath, err) + c.Log(logger.LevelError, "error creating dir: %#v error: %+v", fsPath, err) return c.GetFsError(fs, err) } vfs.SetPathPermissions(fs, fsPath, c.User.GetUID(), c.User.GetGID()) @@ -294,7 +294,7 @@ func (c *BaseConnection) RemoveFile(fs vfs.Fs, fsPath, virtualPath string, info c.Log(logger.LevelDebug, "remove for path %#v handled by pre-delete action", fsPath) } else { if err := fs.Remove(fsPath, false); err != nil { - c.Log(logger.LevelWarn, "failed to remove file/symlink %#v: %+v", fsPath, err) + c.Log(logger.LevelError, "failed to remove file/symlink %#v: %+v", fsPath, err) return c.GetFsError(fs, err) } } @@ -358,16 +358,16 @@ func (c *BaseConnection) RemoveDir(virtualPath string) error { if fs.IsNotExist(err) && fs.HasVirtualFolders() { return nil } - c.Log(logger.LevelWarn, "failed to remove a dir %#v: stat error: %+v", fsPath, err) + c.Log(logger.LevelError, "failed to remove a dir %#v: stat error: %+v", fsPath, err) return c.GetFsError(fs, err) } if !fi.IsDir() || fi.Mode()&os.ModeSymlink != 0 { - c.Log(logger.LevelDebug, "cannot remove %#v is not a directory", fsPath) + c.Log(logger.LevelError, "cannot remove %#v is not a directory", fsPath) return c.GetGenericError(nil) } if err := fs.Remove(fsPath, true); err != nil { - c.Log(logger.LevelWarn, "failed to remove directory %#v: %+v", fsPath, err) + c.Log(logger.LevelError, "failed to remove directory %#v: %+v", fsPath, err) return c.GetFsError(fs, err) } @@ -427,7 +427,7 @@ func (c *BaseConnection) Rename(virtualSourcePath, virtualTargetPath string) err return c.GetGenericError(ErrQuotaExceeded) } if err := fsSrc.Rename(fsSourcePath, fsTargetPath); err != nil { - c.Log(logger.LevelWarn, "failed to rename %#v -> %#v: %+v", fsSourcePath, fsTargetPath, err) + c.Log(logger.LevelError, "failed to rename %#v -> %#v: %+v", fsSourcePath, fsTargetPath, err) return c.GetFsError(fsSrc, err) } vfs.SetPathPermissions(fsDst, fsTargetPath, c.User.GetUID(), c.User.GetGID()) @@ -467,7 +467,7 @@ func (c *BaseConnection) CreateSymlink(virtualSourcePath, virtualTargetPath stri return c.GetPermissionDeniedError() } if err := fs.Symlink(fsSourcePath, fsTargetPath); err != nil { - c.Log(logger.LevelWarn, "failed to create symlink %#v -> %#v: %+v", fsSourcePath, fsTargetPath, err) + c.Log(logger.LevelError, "failed to create symlink %#v -> %#v: %+v", fsSourcePath, fsTargetPath, err) return c.GetFsError(fs, err) } logger.CommandLog(symlinkLogSender, fsSourcePath, fsTargetPath, c.User.Username, "", c.ID, c.protocol, -1, -1, "", @@ -534,7 +534,7 @@ func (c *BaseConnection) handleChmod(fs vfs.Fs, fsPath, pathForPerms string, att return nil } if err := fs.Chmod(c.getRealFsPath(fsPath), attributes.Mode); err != nil { - c.Log(logger.LevelWarn, "failed to chmod path %#v, mode: %v, err: %+v", fsPath, attributes.Mode.String(), err) + c.Log(logger.LevelError, "failed to chmod path %#v, mode: %v, err: %+v", fsPath, attributes.Mode.String(), err) return c.GetFsError(fs, err) } logger.CommandLog(chmodLogSender, fsPath, "", c.User.Username, attributes.Mode.String(), c.ID, c.protocol, @@ -550,7 +550,7 @@ func (c *BaseConnection) handleChown(fs vfs.Fs, fsPath, pathForPerms string, att return nil } if err := fs.Chown(c.getRealFsPath(fsPath), attributes.UID, attributes.GID); err != nil { - c.Log(logger.LevelWarn, "failed to chown path %#v, uid: %v, gid: %v, err: %+v", fsPath, attributes.UID, + c.Log(logger.LevelError, "failed to chown path %#v, uid: %v, gid: %v, err: %+v", fsPath, attributes.UID, attributes.GID, err) return c.GetFsError(fs, err) } @@ -572,7 +572,7 @@ func (c *BaseConnection) handleChtimes(fs vfs.Fs, fsPath, pathForPerms string, a if errors.Is(err, vfs.ErrVfsUnsupported) && Config.SetstatMode == 2 { return nil } - c.Log(logger.LevelWarn, "failed to chtimes for path %#v, access time: %v, modification time: %v, err: %+v", + c.Log(logger.LevelError, "failed to chtimes for path %#v, access time: %v, modification time: %v, err: %+v", fsPath, attributes.Atime, attributes.Mtime, err) return c.GetFsError(fs, err) } @@ -615,7 +615,7 @@ func (c *BaseConnection) SetStat(virtualPath string, attributes *StatAttributes) } if err = c.truncateFile(fs, fsPath, virtualPath, attributes.Size); err != nil { - c.Log(logger.LevelWarn, "failed to truncate path %#v, size: %v, err: %+v", fsPath, attributes.Size, err) + c.Log(logger.LevelError, "failed to truncate path %#v, size: %v, err: %+v", fsPath, attributes.Size, err) return c.GetFsError(fs, err) } logger.CommandLog(truncateLogSender, fsPath, "", c.User.Username, "", c.ID, c.protocol, -1, -1, "", "", @@ -803,7 +803,7 @@ func (c *BaseConnection) hasSpaceForCrossRename(fs vfs.Fs, quotaResult vfs.Quota } fi, err := fs.Lstat(sourcePath) if err != nil { - c.Log(logger.LevelWarn, "cross rename denied, stat error for path %#v: %v", sourcePath, err) + c.Log(logger.LevelError, "cross rename denied, stat error for path %#v: %v", sourcePath, err) return false } var sizeDiff int64 @@ -818,7 +818,7 @@ func (c *BaseConnection) hasSpaceForCrossRename(fs vfs.Fs, quotaResult vfs.Quota } else if fi.IsDir() { filesDiff, sizeDiff, err = fs.GetDirSize(sourcePath) if err != nil { - c.Log(logger.LevelWarn, "cross rename denied, error getting size for directory %#v: %v", sourcePath, err) + c.Log(logger.LevelError, "cross rename denied, error getting size for directory %#v: %v", sourcePath, err) return false } } @@ -915,7 +915,7 @@ func (c *BaseConnection) HasSpace(checkFiles, getUsage bool, requestPath string) result.UsedFiles, result.UsedSize, err = dataprovider.GetUsedQuota(c.User.Username) } if err != nil { - c.Log(logger.LevelWarn, "error getting used quota for %#v request path %#v: %v", c.User.Username, requestPath, err) + c.Log(logger.LevelError, "error getting used quota for %#v request path %#v: %v", c.User.Username, requestPath, err) result.HasSpace = false return result } @@ -1066,7 +1066,7 @@ func (c *BaseConnection) updateQuotaAfterRename(fs vfs.Fs, virtualSourcePath, vi if fi.Mode().IsDir() { numFiles, filesSize, err = fs.GetDirSize(targetPath) if err != nil { - c.Log(logger.LevelWarn, "failed to update quota after rename, error scanning moved folder %#v: %v", + c.Log(logger.LevelError, "failed to update quota after rename, error scanning moved folder %#v: %v", targetPath, err) return err } @@ -1074,7 +1074,7 @@ func (c *BaseConnection) updateQuotaAfterRename(fs vfs.Fs, virtualSourcePath, vi filesSize = fi.Size() } } else { - c.Log(logger.LevelWarn, "failed to update quota after rename, file %#v stat error: %+v", targetPath, err) + c.Log(logger.LevelError, "failed to update quota after rename, file %#v stat error: %+v", targetPath, err) return err } if errSrc == nil && errDst == nil { diff --git a/common/dataretention.go b/common/dataretention.go index f96d0108..9c9f1aa8 100644 --- a/common/dataretention.go +++ b/common/dataretention.go @@ -276,7 +276,7 @@ func (c *RetentionCheck) cleanupFolder(folderPath string) error { return nil } result.Error = fmt.Sprintf("unable to list directory %#v", folderPath) - c.conn.Log(logger.LevelWarn, result.Error) + c.conn.Log(logger.LevelError, result.Error) return err } for _, info := range files { @@ -285,7 +285,7 @@ func (c *RetentionCheck) cleanupFolder(folderPath string) error { if err := c.cleanupFolder(virtualPath); err != nil { result.Elapsed = time.Since(startTime) result.Error = fmt.Sprintf("unable to check folder: %v", err) - c.conn.Log(logger.LevelWarn, "unable to cleanup folder %#v: %v", virtualPath, err) + c.conn.Log(logger.LevelError, "unable to cleanup folder %#v: %v", virtualPath, err) return err } } else { @@ -294,7 +294,7 @@ func (c *RetentionCheck) cleanupFolder(folderPath string) error { if err := c.removeFile(virtualPath, info); err != nil { result.Elapsed = time.Since(startTime) result.Error = fmt.Sprintf("unable to remove file %#v: %v", virtualPath, err) - c.conn.Log(logger.LevelWarn, "unable to remove file %#v, retention %v: %v", + c.conn.Log(logger.LevelError, "unable to remove file %#v, retention %v: %v", virtualPath, retentionTime, err) return err } @@ -340,7 +340,7 @@ func (c *RetentionCheck) Start() { for _, folder := range c.Folders { if folder.Retention > 0 { if err := c.cleanupFolder(folder.Path); err != nil { - c.conn.Log(logger.LevelWarn, "retention check failed, unable to cleanup folder %#v", folder.Path) + c.conn.Log(logger.LevelError, "retention check failed, unable to cleanup folder %#v", folder.Path) c.sendNotifications(time.Since(startTime), err) return } @@ -384,13 +384,13 @@ func (c *RetentionCheck) sendEmailNotification(elapsed time.Duration, errCheck e data["Status"] = "Failed" } if err := smtp.RenderRetentionReportTemplate(body, data); err != nil { - c.conn.Log(logger.LevelWarn, "unable to render retention check template: %v", err) + c.conn.Log(logger.LevelError, "unable to render retention check template: %v", err) return err } startTime := time.Now() subject := fmt.Sprintf("Retention check completed for user %#v", c.conn.User.Username) if err := smtp.SendEmail(c.Email, subject, body.String(), smtp.EmailContentTypeTextHTML); err != nil { - c.conn.Log(logger.LevelWarn, "unable to notify retention check result via email: %v, elapsed: %v", err, + c.conn.Log(logger.LevelError, "unable to notify retention check result via email: %v, elapsed: %v", err, time.Since(startTime)) return err } @@ -425,7 +425,7 @@ func (c *RetentionCheck) sendHookNotification(elapsed time.Duration, errCheck er var url *url.URL url, err := url.Parse(Config.DataRetentionHook) if err != nil { - c.conn.Log(logger.LevelWarn, "invalid data retention hook %#v: %v", Config.DataRetentionHook, err) + c.conn.Log(logger.LevelError, "invalid data retention hook %#v: %v", Config.DataRetentionHook, err) return err } respCode := 0 @@ -447,7 +447,7 @@ func (c *RetentionCheck) sendHookNotification(elapsed time.Duration, errCheck er } if !filepath.IsAbs(Config.DataRetentionHook) { err := fmt.Errorf("invalid data retention hook %#v", Config.DataRetentionHook) - c.conn.Log(logger.LevelWarn, "%v", err) + c.conn.Log(logger.LevelError, "%v", err) return err } ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) diff --git a/common/transfer.go b/common/transfer.go index 89c80329..2a50650d 100644 --- a/common/transfer.go +++ b/common/transfer.go @@ -191,7 +191,7 @@ func (t *BaseTransfer) TransferError(err error) { t.cancelFn() } elapsed := time.Since(t.start).Nanoseconds() / 1000000 - t.Connection.Log(logger.LevelWarn, "Unexpected error for transfer, path: %#v, error: \"%v\" bytes sent: %v, "+ + t.Connection.Log(logger.LevelError, "Unexpected error for transfer, path: %#v, error: \"%v\" bytes sent: %v, "+ "bytes received: %v transfer running since %v ms", t.fsPath, t.ErrTransfer, atomic.LoadInt64(&t.BytesSent), atomic.LoadInt64(&t.BytesReceived), elapsed) } @@ -270,7 +270,7 @@ func (t *BaseTransfer) Close() error { ExecuteActionNotification(t.Connection, operationUpload, t.fsPath, t.requestPath, "", "", "", fileSize, t.ErrTransfer) } if t.ErrTransfer != nil { - t.Connection.Log(logger.LevelWarn, "transfer error: %v, path: %#v", t.ErrTransfer, t.fsPath) + t.Connection.Log(logger.LevelError, "transfer error: %v, path: %#v", t.ErrTransfer, t.fsPath) if err == nil { err = t.ErrTransfer } diff --git a/dataprovider/actions.go b/dataprovider/actions.go index 9c3d54f7..445e6b5f 100644 --- a/dataprovider/actions.go +++ b/dataprovider/actions.go @@ -45,14 +45,15 @@ func executeAction(operation, executor, ip, objectType, objectName string, objec go func() { dataAsJSON, err := object.RenderAsJSON(operation != operationDelete) if err != nil { - providerLog(logger.LevelWarn, "unable to serialize user as JSON for operation %#v: %v", operation, err) + providerLog(logger.LevelError, "unable to serialize user as JSON for operation %#v: %v", operation, err) return } if strings.HasPrefix(config.Actions.Hook, "http") { var url *url.URL url, err := url.Parse(config.Actions.Hook) if err != nil { - providerLog(logger.LevelWarn, "Invalid http_notification_url %#v for operation %#v: %v", config.Actions.Hook, operation, err) + providerLog(logger.LevelError, "Invalid http_notification_url %#v for operation %#v: %v", + config.Actions.Hook, operation, err) return } q := url.Query() diff --git a/dataprovider/admin.go b/dataprovider/admin.go index a6684028..5042cc2f 100644 --- a/dataprovider/admin.go +++ b/dataprovider/admin.go @@ -303,7 +303,7 @@ func (a *Admin) RenderAsJSON(reload bool) ([]byte, error) { if reload { admin, err := provider.adminExists(a.Username) if err != nil { - providerLog(logger.LevelWarn, "unable to reload admin before rendering as json: %v", err) + providerLog(logger.LevelError, "unable to reload admin before rendering as json: %v", err) return nil, err } admin.HideConfidentialData() diff --git a/dataprovider/apikey.go b/dataprovider/apikey.go index c1bd93c4..468dd479 100644 --- a/dataprovider/apikey.go +++ b/dataprovider/apikey.go @@ -82,7 +82,7 @@ func (k *APIKey) RenderAsJSON(reload bool) ([]byte, error) { if reload { apiKey, err := provider.apiKeyExists(k.KeyID) if err != nil { - providerLog(logger.LevelWarn, "unable to reload api key before rendering as json: %v", err) + providerLog(logger.LevelError, "unable to reload api key before rendering as json: %v", err) return nil, err } apiKey.HideConfidentialData() diff --git a/dataprovider/bolt.go b/dataprovider/bolt.go index 1d21e26d..e3896541 100644 --- a/dataprovider/bolt.go +++ b/dataprovider/bolt.go @@ -66,13 +66,13 @@ func initializeBoltProvider(basePath string) error { _, e := tx.CreateBucketIfNotExists(bucket) return e }); err != nil { - providerLog(logger.LevelWarn, "error creating bucket %#v: %v", string(bucket), err) + providerLog(logger.LevelError, "error creating bucket %#v: %v", string(bucket), err) } } provider = &BoltProvider{dbHandle: dbHandle} } else { - providerLog(logger.LevelWarn, "error creating bolt key/value store handler: %v", err) + providerLog(logger.LevelError, "error creating bolt key/value store handler: %v", err) } return err } @@ -288,7 +288,7 @@ func (p *BoltProvider) updateQuota(username string, filesAdd int, sizeAdd int64, func (p *BoltProvider) getUsedQuota(username string) (int, int64, error) { user, err := p.userExists(username) if err != nil { - providerLog(logger.LevelWarn, "unable to get quota for user %v error: %v", username, err) + providerLog(logger.LevelError, "unable to get quota for user %v error: %v", username, err) return 0, 0, err } return user.UsedQuotaFiles, user.UsedQuotaSize, err @@ -923,7 +923,7 @@ func (p *BoltProvider) updateFolderQuota(name string, filesAdd int, sizeAdd int6 func (p *BoltProvider) getUsedFolderQuota(name string) (int, int64, error) { folder, err := p.getFolderByName(name) if err != nil { - providerLog(logger.LevelWarn, "unable to get quota for folder %#v error: %v", name, err) + providerLog(logger.LevelError, "unable to get quota for folder %#v error: %v", name, err) return 0, 0, err } return folder.UsedQuotaFiles, folder.UsedQuotaSize, err @@ -1402,7 +1402,7 @@ func (p *BoltProvider) migrateDatabase() error { return updateBoltDatabaseVersion(p.dbHandle, 14) default: if version > boltDatabaseVersion { - providerLog(logger.LevelWarn, "database version %v is newer than the supported one: %v", version, + providerLog(logger.LevelError, "database version %v is newer than the supported one: %v", version, boltDatabaseVersion) logger.WarnToConsole("database version %v is newer than the supported one: %v", version, boltDatabaseVersion) diff --git a/dataprovider/dataprovider.go b/dataprovider/dataprovider.go index faf8d4e5..c4679355 100644 --- a/dataprovider/dataprovider.go +++ b/dataprovider/dataprovider.go @@ -494,7 +494,7 @@ func Initialize(cnf Config, basePath string, checkAdmins bool) error { err = provider.initializeDatabase() if err != nil && err != ErrNoInitRequired { logger.WarnToConsole("Unable to initialize data provider: %v", err) - providerLog(logger.LevelWarn, "Unable to initialize data provider: %v", err) + providerLog(logger.LevelError, "Unable to initialize data provider: %v", err) return err } if err == nil { @@ -502,13 +502,13 @@ func Initialize(cnf Config, basePath string, checkAdmins bool) error { } err = provider.migrateDatabase() if err != nil && err != ErrNoInitRequired { - providerLog(logger.LevelWarn, "database migration error: %v", err) + providerLog(logger.LevelError, "database migration error: %v", err) return err } if checkAdmins && cnf.CreateDefaultAdmin { err = checkDefaultAdmin() if err != nil { - providerLog(logger.LevelWarn, "check default admin error: %v", err) + providerLog(logger.LevelError, "erro checking the default admin: %v", err) return err } } @@ -547,7 +547,7 @@ func validateHooks() error { } _, err := os.Stat(hook) if err != nil { - providerLog(logger.LevelWarn, "invalid hook: %v", err) + providerLog(logger.LevelError, "invalid hook: %v", err) return err } } @@ -568,7 +568,7 @@ func initializeHashingAlgo(cnf *Config) error { if config.PasswordHashing.BcryptOptions.Cost > bcrypt.MaxCost { err := fmt.Errorf("invalid bcrypt cost %v, max allowed %v", config.PasswordHashing.BcryptOptions.Cost, bcrypt.MaxCost) logger.WarnToConsole("Unable to initialize data provider: %v", err) - providerLog(logger.LevelWarn, "Unable to initialize data provider: %v", err) + providerLog(logger.LevelError, "Unable to initialize data provider: %v", err) return err } } @@ -1878,7 +1878,7 @@ func isPasswordOK(user *User, password string) (bool, error) { } else if strings.HasPrefix(user.Password, argonPwdPrefix) { match, err = argon2id.ComparePasswordAndHash(password, user.Password) if err != nil { - providerLog(logger.LevelWarn, "error comparing password with argon hash: %v", err) + providerLog(logger.LevelError, "error comparing password with argon hash: %v", err) return match, err } } else if util.IsStringPrefixInSlice(user.Password, pbkdfPwdPrefixes) { @@ -1975,7 +1975,7 @@ func checkUserPasscode(user *User, password, protocol string) (string, error) { } err := user.Filters.TOTPConfig.Secret.TryDecrypt() if err != nil { - providerLog(logger.LevelWarn, "unable to decrypt TOTP secret for user %#v, protocol %v, err: %v", + providerLog(logger.LevelError, "unable to decrypt TOTP secret for user %#v, protocol %v, err: %v", user.Username, protocol, err) return "", err } @@ -2006,7 +2006,7 @@ func checkUserAndPubKey(user *User, pubKey []byte) (User, string, error) { for i, k := range user.PublicKeys { storedPubKey, comment, _, _, err := ssh.ParseAuthorizedKey([]byte(k)) if err != nil { - providerLog(logger.LevelWarn, "error parsing stored public key %d for user %v: %v", i, user.Username, err) + providerLog(logger.LevelError, "error parsing stored public key %d for user %v: %v", i, user.Username, err) return *user, "", err } if bytes.Equal(storedPubKey.Marshal(), pubKey) { @@ -2153,7 +2153,7 @@ func checkCacheUpdates() { checkTime := util.GetTimeAsMsSinceEpoch(time.Now()) users, err := provider.getRecentlyUpdatedUsers(lastCachesUpdate) if err != nil { - providerLog(logger.LevelWarn, "unable to get recently updated users: %v", err) + providerLog(logger.LevelError, "unable to get recently updated users: %v", err) return } for _, user := range users { @@ -2171,7 +2171,7 @@ func startUpdateCachesTimer() { return } if !util.IsStringInSlice(config.Driver, sharedProviders) { - providerLog(logger.LevelWarn, "update caches not supported for provider %v", config.Driver) + providerLog(logger.LevelError, "update caches not supported for provider %v", config.Driver) return } lastCachesUpdate = util.GetTimeAsMsSinceEpoch(time.Now()) @@ -2210,7 +2210,7 @@ func startAvailabilityTimer() { func checkDataprovider() { err := provider.checkAvailability() if err != nil { - providerLog(logger.LevelWarn, "check availability error: %v", err) + providerLog(logger.LevelError, "check availability error: %v", err) } metric.UpdateDataProviderAvailability(err) } @@ -2229,12 +2229,12 @@ func terminateInteractiveAuthProgram(cmd *exec.Cmd, isFinished bool) { func sendKeyboardAuthHTTPReq(url string, request *plugin.KeyboardAuthRequest) (*plugin.KeyboardAuthResponse, error) { reqAsJSON, err := json.Marshal(request) if err != nil { - providerLog(logger.LevelWarn, "error serializing keyboard interactive auth request: %v", err) + providerLog(logger.LevelError, "error serializing keyboard interactive auth request: %v", err) return nil, err } resp, err := httpclient.Post(url, "application/json", bytes.NewBuffer(reqAsJSON)) if err != nil { - providerLog(logger.LevelWarn, "error getting keyboard interactive auth hook HTTP response: %v", err) + providerLog(logger.LevelError, "error getting keyboard interactive auth hook HTTP response: %v", err) return nil, err } defer resp.Body.Close() @@ -2263,7 +2263,7 @@ func doBuiltinKeyboardInteractiveAuth(user *User, client ssh.KeyboardInteractive } err = user.Filters.TOTPConfig.Secret.TryDecrypt() if err != nil { - providerLog(logger.LevelWarn, "unable to decrypt TOTP secret for user %#v, protocol %v, err: %v", + providerLog(logger.LevelError, "unable to decrypt TOTP secret for user %#v, protocol %v, err: %v", user.Username, protocol, err) return 0, err } @@ -2389,7 +2389,7 @@ func getKeyboardInteractiveAnswers(client ssh.KeyboardInteractiveChallenge, resp } err := user.Filters.TOTPConfig.Secret.TryDecrypt() if err != nil { - providerLog(logger.LevelWarn, "unable to decrypt TOTP secret for user %#v, protocol %v, err: %v", + providerLog(logger.LevelError, "unable to decrypt TOTP secret for user %#v, protocol %v, err: %v", user.Username, protocol, err) return answers, fmt.Errorf("unable to decrypt TOTP secret: %w", err) } @@ -2554,7 +2554,7 @@ func getPasswordHookResponse(username, password, ip, protocol string) ([]byte, e } resp, err := httpclient.Post(config.CheckPasswordHook, "application/json", bytes.NewBuffer(reqAsJSON)) if err != nil { - providerLog(logger.LevelWarn, "error getting check password hook response: %v", err) + providerLog(logger.LevelError, "error getting check password hook response: %v", err) return result, err } defer resp.Body.Close() @@ -2599,7 +2599,7 @@ func getPreLoginHookResponse(loginMethod, ip, protocol string, userAsJSON []byte var result []byte url, err := url.Parse(config.PreLoginHook) if err != nil { - providerLog(logger.LevelWarn, "invalid url for pre-login hook %#v, error: %v", config.PreLoginHook, err) + providerLog(logger.LevelError, "invalid url for pre-login hook %#v, error: %v", config.PreLoginHook, err) return result, err } q := url.Query() @@ -2723,7 +2723,7 @@ func ExecutePostLoginHook(user *User, loginMethod, ip, protocol string, err erro user.PrepareForRendering() userAsJSON, err := json.Marshal(user) if err != nil { - providerLog(logger.LevelWarn, "error serializing user in post login hook: %v", err) + providerLog(logger.LevelError, "error serializing user in post login hook: %v", err) return } if strings.HasPrefix(config.PostLoginHook, "http") { @@ -2791,7 +2791,7 @@ func getExternalAuthResponse(username, password, pkey, keyboardInteractive, ip, } authRequestAsJSON, err := json.Marshal(authRequest) if err != nil { - providerLog(logger.LevelWarn, "error serializing external auth request: %v", err) + providerLog(logger.LevelError, "error serializing external auth request: %v", err) return result, err } resp, err := httpclient.Post(config.ExternalAuthHook, "application/json", bytes.NewBuffer(authRequestAsJSON)) diff --git a/dataprovider/memory.go b/dataprovider/memory.go index b8e4348f..2078194d 100644 --- a/dataprovider/memory.go +++ b/dataprovider/memory.go @@ -216,7 +216,7 @@ func (p *MemoryProvider) updateQuota(username string, filesAdd int, sizeAdd int6 } user, err := p.userExistsInternal(username) if err != nil { - providerLog(logger.LevelWarn, "unable to update quota for user %#v error: %v", username, err) + providerLog(logger.LevelError, "unable to update quota for user %#v error: %v", username, err) return err } if reset { @@ -241,7 +241,7 @@ func (p *MemoryProvider) getUsedQuota(username string) (int, int64, error) { } user, err := p.userExistsInternal(username) if err != nil { - providerLog(logger.LevelWarn, "unable to get quota for user %#v error: %v", username, err) + providerLog(logger.LevelError, "unable to get quota for user %#v error: %v", username, err) return 0, 0, err } return user.UsedQuotaFiles, user.UsedQuotaSize, err @@ -590,7 +590,7 @@ func (p *MemoryProvider) updateFolderQuota(name string, filesAdd int, sizeAdd in } folder, err := p.folderExistsInternal(name) if err != nil { - providerLog(logger.LevelWarn, "unable to update quota for folder %#v error: %v", name, err) + providerLog(logger.LevelError, "unable to update quota for folder %#v error: %v", name, err) return err } if reset { @@ -613,7 +613,7 @@ func (p *MemoryProvider) getUsedFolderQuota(name string) (int, int64, error) { } folder, err := p.folderExistsInternal(name) if err != nil { - providerLog(logger.LevelWarn, "unable to get quota for folder %#v error: %v", name, err) + providerLog(logger.LevelError, "unable to get quota for folder %#v error: %v", name, err) return 0, 0, err } return folder.UsedQuotaFiles, folder.UsedQuotaSize, err @@ -1309,27 +1309,27 @@ func (p *MemoryProvider) reloadConfig() error { providerLog(logger.LevelDebug, "loading dump from file: %#v", p.dbHandle.configFile) fi, err := os.Stat(p.dbHandle.configFile) if err != nil { - providerLog(logger.LevelWarn, "error loading dump: %v", err) + providerLog(logger.LevelError, "error loading dump: %v", err) return err } if fi.Size() == 0 { err = errors.New("dump configuration file is invalid, its size must be > 0") - providerLog(logger.LevelWarn, "error loading dump: %v", err) + providerLog(logger.LevelError, "error loading dump: %v", err) return err } if fi.Size() > 10485760 { err = errors.New("dump configuration file is invalid, its size must be <= 10485760 bytes") - providerLog(logger.LevelWarn, "error loading dump: %v", err) + providerLog(logger.LevelError, "error loading dump: %v", err) return err } content, err := os.ReadFile(p.dbHandle.configFile) if err != nil { - providerLog(logger.LevelWarn, "error loading dump: %v", err) + providerLog(logger.LevelError, "error loading dump: %v", err) return err } dump, err := ParseDumpData(content) if err != nil { - providerLog(logger.LevelWarn, "error loading dump: %v", err) + providerLog(logger.LevelError, "error loading dump: %v", err) return err } p.clear() @@ -1367,13 +1367,13 @@ func (p *MemoryProvider) restoreShares(dump *BackupData) error { share.ID = s.ID err = UpdateShare(&share, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error updating share %#v: %v", share.ShareID, err) + providerLog(logger.LevelError, "error updating share %#v: %v", share.ShareID, err) return err } } else { err = AddShare(&share, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error adding share %#v: %v", share.ShareID, err) + providerLog(logger.LevelError, "error adding share %#v: %v", share.ShareID, err) return err } } @@ -1392,13 +1392,13 @@ func (p *MemoryProvider) restoreAPIKeys(dump *BackupData) error { apiKey.ID = k.ID err = UpdateAPIKey(&apiKey, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error updating API key %#v: %v", apiKey.KeyID, err) + providerLog(logger.LevelError, "error updating API key %#v: %v", apiKey.KeyID, err) return err } } else { err = AddAPIKey(&apiKey, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error adding API key %#v: %v", apiKey.KeyID, err) + providerLog(logger.LevelError, "error adding API key %#v: %v", apiKey.KeyID, err) return err } } @@ -1414,13 +1414,13 @@ func (p *MemoryProvider) restoreAdmins(dump *BackupData) error { admin.ID = a.ID err = UpdateAdmin(&admin, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error updating admin %#v: %v", admin.Username, err) + providerLog(logger.LevelError, "error updating admin %#v: %v", admin.Username, err) return err } } else { err = AddAdmin(&admin, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error adding admin %#v: %v", admin.Username, err) + providerLog(logger.LevelError, "error adding admin %#v: %v", admin.Username, err) return err } } @@ -1436,14 +1436,14 @@ func (p *MemoryProvider) restoreFolders(dump *BackupData) error { folder.ID = f.ID err = UpdateFolder(&folder, f.Users, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error updating folder %#v: %v", folder.Name, err) + providerLog(logger.LevelError, "error updating folder %#v: %v", folder.Name, err) return err } } else { folder.Users = nil err = AddFolder(&folder) if err != nil { - providerLog(logger.LevelWarn, "error adding folder %#v: %v", folder.Name, err) + providerLog(logger.LevelError, "error adding folder %#v: %v", folder.Name, err) return err } } @@ -1459,13 +1459,13 @@ func (p *MemoryProvider) restoreUsers(dump *BackupData) error { user.ID = u.ID err = UpdateUser(&user, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error updating user %#v: %v", user.Username, err) + providerLog(logger.LevelError, "error updating user %#v: %v", user.Username, err) return err } } else { err = AddUser(&user, ActionExecutorSystem, "") if err != nil { - providerLog(logger.LevelWarn, "error adding user %#v: %v", user.Username, err) + providerLog(logger.LevelError, "error adding user %#v: %v", user.Username, err) return err } } diff --git a/dataprovider/mysql.go b/dataprovider/mysql.go index 04e57fff..f67542f8 100644 --- a/dataprovider/mysql.go +++ b/dataprovider/mysql.go @@ -109,7 +109,7 @@ func initializeMySQLProvider() error { dbHandle.SetConnMaxLifetime(240 * time.Second) provider = &MySQLProvider{dbHandle: dbHandle} } else { - providerLog(logger.LevelWarn, "error creating mysql database handler, connection string: %#v, error: %v", + providerLog(logger.LevelError, "error creating mysql database handler, connection string: %#v, error: %v", getMySQLConnectionString(true), err) } return err @@ -364,7 +364,7 @@ func (p *MySQLProvider) migrateDatabase() error { return updateMySQLDatabaseFromV13(p.dbHandle) default: if version > sqlDatabaseVersion { - providerLog(logger.LevelWarn, "database version %v is newer than the supported one: %v", version, + providerLog(logger.LevelError, "database version %v is newer than the supported one: %v", version, sqlDatabaseVersion) logger.WarnToConsole("database version %v is newer than the supported one: %v", version, sqlDatabaseVersion) diff --git a/dataprovider/pgsql.go b/dataprovider/pgsql.go index 6ae679fb..6ef50e95 100644 --- a/dataprovider/pgsql.go +++ b/dataprovider/pgsql.go @@ -123,7 +123,7 @@ func initializePGSQLProvider() error { dbHandle.SetConnMaxLifetime(240 * time.Second) provider = &PGSQLProvider{dbHandle: dbHandle} } else { - providerLog(logger.LevelWarn, "error creating postgres database handler, connection string: %#v, error: %v", + providerLog(logger.LevelError, "error creating postgres database handler, connection string: %#v, error: %v", getPGSQLConnectionString(true), err) } return err @@ -385,7 +385,7 @@ func (p *PGSQLProvider) migrateDatabase() error { return updatePGSQLDatabaseFromV13(p.dbHandle) default: if version > sqlDatabaseVersion { - providerLog(logger.LevelWarn, "database version %v is newer than the supported one: %v", version, + providerLog(logger.LevelError, "database version %v is newer than the supported one: %v", version, sqlDatabaseVersion) logger.WarnToConsole("database version %v is newer than the supported one: %v", version, sqlDatabaseVersion) diff --git a/dataprovider/share.go b/dataprovider/share.go index 1a190d98..5ad904fb 100644 --- a/dataprovider/share.go +++ b/dataprovider/share.go @@ -137,7 +137,7 @@ func (s *Share) RenderAsJSON(reload bool) ([]byte, error) { if reload { share, err := provider.shareExists(s.ShareID, s.Username) if err != nil { - providerLog(logger.LevelWarn, "unable to reload share before rendering as json: %v", err) + providerLog(logger.LevelError, "unable to reload share before rendering as json: %v", err) return nil, err } share.HideConfidentialData() diff --git a/dataprovider/sqlcommon.go b/dataprovider/sqlcommon.go index dfed368b..9972e0d7 100644 --- a/dataprovider/sqlcommon.go +++ b/dataprovider/sqlcommon.go @@ -46,7 +46,7 @@ func sqlCommonGetShareByID(shareID, username string, dbHandle sqlQuerier) (Share q := getShareByIDQuery(filterUser) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return share, err } defer stmt.Close() @@ -88,7 +88,7 @@ func sqlCommonAddShare(share *Share, dbHandle *sql.DB) error { q := getAddShareQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -147,7 +147,7 @@ func sqlCommonUpdateShare(share *Share, dbHandle *sql.DB) error { } stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -177,7 +177,7 @@ func sqlCommonDeleteShare(share *Share, dbHandle *sql.DB) error { q := getDeleteShareQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -193,7 +193,7 @@ func sqlCommonGetShares(limit, offset int, order, username string, dbHandle sqlQ q := getSharesQuery(order) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -224,7 +224,7 @@ func sqlCommonDumpShares(dbHandle sqlQuerier) ([]Share, error) { q := getDumpSharesQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -254,7 +254,7 @@ func sqlCommonGetAPIKeyByID(keyID string, dbHandle sqlQuerier) (APIKey, error) { q := getAPIKeyByIDQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return apiKey, err } defer stmt.Close() @@ -283,7 +283,7 @@ func sqlCommonAddAPIKey(apiKey *APIKey, dbHandle *sql.DB) error { q := getAddAPIKeyQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -310,7 +310,7 @@ func sqlCommonUpdateAPIKey(apiKey *APIKey, dbHandle *sql.DB) error { q := getUpdateAPIKeyQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -326,7 +326,7 @@ func sqlCommonDeleteAPIKey(apiKey *APIKey, dbHandle *sql.DB) error { q := getDeleteAPIKeyQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -342,7 +342,7 @@ func sqlCommonGetAPIKeys(limit, offset int, order string, dbHandle sqlQuerier) ( q := getAPIKeysQuery(order) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -381,7 +381,7 @@ func sqlCommonDumpAPIKeys(dbHandle sqlQuerier) ([]APIKey, error) { q := getDumpAPIKeysQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -418,7 +418,7 @@ func sqlCommonGetAdminByUsername(username string, dbHandle sqlQuerier) (Admin, e q := getAdminByUsernameQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return admin, err } defer stmt.Close() @@ -448,7 +448,7 @@ func sqlCommonAddAdmin(admin *Admin, dbHandle *sql.DB) error { q := getAddAdminQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -480,7 +480,7 @@ func sqlCommonUpdateAdmin(admin *Admin, dbHandle *sql.DB) error { q := getUpdateAdminQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -506,7 +506,7 @@ func sqlCommonDeleteAdmin(admin *Admin, dbHandle *sql.DB) error { q := getDeleteAdminQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -522,7 +522,7 @@ func sqlCommonGetAdmins(limit, offset int, order string, dbHandle sqlQuerier) ([ q := getAdminsQuery(order) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -553,7 +553,7 @@ func sqlCommonDumpAdmins(dbHandle sqlQuerier) ([]Admin, error) { q := getDumpAdminsQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -582,7 +582,7 @@ func sqlCommonGetUserByUsername(username string, dbHandle sqlQuerier) (User, err q := getUserByUsernameQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return user, err } defer stmt.Close() @@ -646,7 +646,7 @@ func sqlCommonUpdateQuota(username string, filesAdd int, sizeAdd int64, reset bo q := getUpdateQuotaQuery(reset) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -655,7 +655,7 @@ func sqlCommonUpdateQuota(username string, filesAdd int, sizeAdd int64, reset bo providerLog(logger.LevelDebug, "quota updated for user %#v, files increment: %v size increment: %v is reset? %v", username, filesAdd, sizeAdd, reset) } else { - providerLog(logger.LevelWarn, "error updating quota for user %#v: %v", username, err) + providerLog(logger.LevelError, "error updating quota for user %#v: %v", username, err) } return err } @@ -666,7 +666,7 @@ func sqlCommonGetUsedQuota(username string, dbHandle *sql.DB) (int, int64, error q := getQuotaQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return 0, 0, err } defer stmt.Close() @@ -675,7 +675,7 @@ func sqlCommonGetUsedQuota(username string, dbHandle *sql.DB) (int, int64, error var usedSize int64 err = stmt.QueryRowContext(ctx, username).Scan(&usedSize, &usedFiles) if err != nil { - providerLog(logger.LevelWarn, "error getting quota for user: %v, error: %v", username, err) + providerLog(logger.LevelError, "error getting quota for user: %v, error: %v", username, err) return 0, 0, err } return usedFiles, usedSize, err @@ -687,7 +687,7 @@ func sqlCommonUpdateShareLastUse(shareID string, numTokens int, dbHandle *sql.DB q := getUpdateShareLastUseQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -706,7 +706,7 @@ func sqlCommonUpdateAPIKeyLastUse(keyID string, dbHandle *sql.DB) error { q := getUpdateAPIKeyLastUseQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -725,7 +725,7 @@ func sqlCommonUpdateAdminLastLogin(username string, dbHandle *sql.DB) error { q := getUpdateAdminLastLoginQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -744,7 +744,7 @@ func sqlCommonSetUpdatedAt(username string, dbHandle *sql.DB) { q := getSetUpdateAtQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return } defer stmt.Close() @@ -762,7 +762,7 @@ func sqlCommonUpdateLastLogin(username string, dbHandle *sql.DB) error { q := getUpdateLastLoginQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -787,7 +787,7 @@ func sqlCommonAddUser(user *User, dbHandle *sql.DB) error { q := getAddUserQuery() stmt, err := tx.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -830,7 +830,7 @@ func sqlCommonUpdateUser(user *User, dbHandle *sql.DB) error { q := getUpdateUserQuery() stmt, err := tx.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -867,7 +867,7 @@ func sqlCommonDeleteUser(user *User, dbHandle *sql.DB) error { q := getDeleteUserQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -882,7 +882,7 @@ func sqlCommonDumpUsers(dbHandle sqlQuerier) ([]User, error) { q := getDumpUsersQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -917,7 +917,7 @@ func sqlCommonGetRecentlyUpdatedUsers(after int64, dbHandle sqlQuerier) ([]User, q := getRecentlyUpdatedUsersQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -947,7 +947,7 @@ func sqlCommonGetUsers(limit int, offset int, order string, dbHandle sqlQuerier) q := getUsersQuery(order) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -1119,7 +1119,7 @@ func getUserFromDbRow(row sqlScanner) (User, error) { perms := make(map[string][]string) err = json.Unmarshal([]byte(permissions.String), &perms) if err != nil { - providerLog(logger.LevelWarn, "unable to deserialize permissions for user %#v: %v", user.Username, err) + providerLog(logger.LevelError, "unable to deserialize permissions for user %#v: %v", user.Username, err) return user, fmt.Errorf("unable to deserialize permissions for user %#v: %v", user.Username, err) } user.Permissions = perms @@ -1156,7 +1156,7 @@ func sqlCommonCheckFolderExists(ctx context.Context, name string, dbHandle sqlQu q := checkFolderNameQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -1169,7 +1169,7 @@ func sqlCommonGetFolder(ctx context.Context, name string, dbHandle sqlQuerier) ( q := getFolderByNameQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return folder, err } defer stmt.Close() @@ -1254,7 +1254,7 @@ func sqlCommonAddFolder(folder *vfs.BaseVirtualFolder, dbHandle sqlQuerier) erro q := getAddFolderQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -1277,7 +1277,7 @@ func sqlCommonUpdateFolder(folder *vfs.BaseVirtualFolder, dbHandle sqlQuerier) e q := getUpdateFolderQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -1291,7 +1291,7 @@ func sqlCommonDeleteFolder(folder *vfs.BaseVirtualFolder, dbHandle sqlQuerier) e q := getDeleteFolderQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -1306,7 +1306,7 @@ func sqlCommonDumpFolders(dbHandle sqlQuerier) ([]vfs.BaseVirtualFolder, error) q := getDumpFoldersQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -1352,7 +1352,7 @@ func sqlCommonGetFolders(limit, offset int, order string, dbHandle sqlQuerier) ( q := getFoldersQuery(order) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -1398,7 +1398,7 @@ func sqlCommonClearFolderMapping(ctx context.Context, user *User, dbHandle sqlQu q := getClearFolderMappingQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -1410,7 +1410,7 @@ func sqlCommonAddFolderMapping(ctx context.Context, user *User, folder *vfs.Virt q := getAddFolderMappingQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -1459,7 +1459,7 @@ func getUsersWithVirtualFolders(ctx context.Context, users []User, dbHandle sqlQ q := getRelatedFoldersForUsersQuery(users) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -1519,7 +1519,7 @@ func getVirtualFoldersWithUsers(folders []vfs.BaseVirtualFolder, dbHandle sqlQue q := getRelatedUsersForFoldersQuery(folders) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -1557,7 +1557,7 @@ func sqlCommonUpdateFolderQuota(name string, filesAdd int, sizeAdd int64, reset q := getUpdateFolderQuotaQuery(reset) stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() @@ -1577,7 +1577,7 @@ func sqlCommonGetFolderUsedQuota(mappedPath string, dbHandle *sql.DB) (int, int6 q := getQuotaFolderQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return 0, 0, err } defer stmt.Close() @@ -1586,7 +1586,7 @@ func sqlCommonGetFolderUsedQuota(mappedPath string, dbHandle *sql.DB) (int, int6 var usedSize int64 err = stmt.QueryRowContext(ctx, mappedPath).Scan(&usedSize, &usedFiles) if err != nil { - providerLog(logger.LevelWarn, "error getting quota for folder: %v, error: %v", mappedPath, err) + providerLog(logger.LevelError, "error getting quota for folder: %v, error: %v", mappedPath, err) return 0, 0, err } return usedFiles, usedSize, err @@ -1623,7 +1623,7 @@ func getRelatedValuesForAPIKeys(ctx context.Context, apiKeys []APIKey, dbHandle } stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return nil, err } defer stmt.Close() @@ -1687,7 +1687,7 @@ func sqlCommonGetDatabaseVersion(dbHandle *sql.DB, showInitWarn bool) (schemaVer q := getDatabaseVersionQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) if showInitWarn && strings.Contains(err.Error(), sqlTableSchemaVersion) { logger.WarnToConsole("database query error, did you forgot to run the \"initprovider\" command?") } @@ -1703,7 +1703,7 @@ func sqlCommonUpdateDatabaseVersion(ctx context.Context, dbHandle sqlQuerier, ve q := getUpdateDBVersionQuery() stmt, err := dbHandle.PrepareContext(ctx, q) if err != nil { - providerLog(logger.LevelWarn, "error preparing database query %#v: %v", q, err) + providerLog(logger.LevelError, "error preparing database query %#v: %v", q, err) return err } defer stmt.Close() diff --git a/dataprovider/sqlite.go b/dataprovider/sqlite.go index 29b82838..008d248c 100644 --- a/dataprovider/sqlite.go +++ b/dataprovider/sqlite.go @@ -119,7 +119,7 @@ func initializeSQLiteProvider(basePath string) error { dbHandle.SetMaxOpenConns(1) provider = &SQLiteProvider{dbHandle: dbHandle} } else { - providerLog(logger.LevelWarn, "error creating sqlite database handler, connection string: %#v, error: %v", + providerLog(logger.LevelError, "error creating sqlite database handler, connection string: %#v, error: %v", connectionString, err) } return err @@ -361,7 +361,7 @@ func (p *SQLiteProvider) migrateDatabase() error { return updateSQLiteDatabaseFromV13(p.dbHandle) default: if version > sqlDatabaseVersion { - providerLog(logger.LevelWarn, "database version %v is newer than the supported one: %v", version, + providerLog(logger.LevelError, "database version %v is newer than the supported one: %v", version, sqlDatabaseVersion) logger.WarnToConsole("database version %v is newer than the supported one: %v", version, sqlDatabaseVersion) diff --git a/dataprovider/user.go b/dataprovider/user.go index d1cb977f..dc1e9ac1 100644 --- a/dataprovider/user.go +++ b/dataprovider/user.go @@ -238,7 +238,7 @@ func (u *User) RenderAsJSON(reload bool) ([]byte, error) { if reload { user, err := provider.userExists(u.Username) if err != nil { - providerLog(logger.LevelWarn, "unable to reload user before rendering as json: %v", err) + providerLog(logger.LevelError, "unable to reload user before rendering as json: %v", err) return nil, err } user.PrepareForRendering() diff --git a/ftpd/handler.go b/ftpd/handler.go index 3c6970c6..0a8b1812 100644 --- a/ftpd/handler.go +++ b/ftpd/handler.go @@ -113,12 +113,12 @@ func (c *Connection) Remove(name string) error { var fi os.FileInfo if fi, err = fs.Lstat(p); err != nil { - c.Log(logger.LevelWarn, "failed to remove file %#v: stat error: %+v", p, err) + c.Log(logger.LevelError, "failed to remove file %#v: stat error: %+v", p, err) return c.GetFsError(fs, err) } if fi.IsDir() && fi.Mode()&os.ModeSymlink == 0 { - c.Log(logger.LevelDebug, "cannot remove %#v is not a file/symlink", p) + c.Log(logger.LevelError, "cannot remove %#v is not a file/symlink", p) return c.GetGenericError(nil) } return c.RemoveFile(fs, p, name, fi) @@ -332,7 +332,7 @@ func (c *Connection) downloadFile(fs vfs.Fs, fsPath, ftpPath string, offset int6 file, r, cancelFn, err := fs.Open(fsPath, offset) if err != nil { - c.Log(logger.LevelWarn, "could not open file %#v for reading: %+v", fsPath, err) + c.Log(logger.LevelError, "could not open file %#v for reading: %+v", fsPath, err) return nil, c.GetFsError(fs, err) } @@ -370,7 +370,7 @@ func (c *Connection) uploadFile(fs vfs.Fs, fsPath, ftpPath string, flags int) (f // This happen if we upload a file that has the same name of an existing directory if stat.IsDir() { - c.Log(logger.LevelWarn, "attempted to open a directory for writing to: %#v", fsPath) + c.Log(logger.LevelError, "attempted to open a directory for writing to: %#v", fsPath) return nil, c.GetOpUnsupportedError() } @@ -393,7 +393,7 @@ func (c *Connection) handleFTPUploadToNewFile(fs vfs.Fs, resolvedPath, filePath, } file, w, cancelFn, err := fs.Create(filePath, 0) if err != nil { - c.Log(logger.LevelWarn, "error creating file %#v: %+v", resolvedPath, err) + c.Log(logger.LevelError, "error creating file %#v: %+v", resolvedPath, err) return nil, c.GetFsError(fs, err) } @@ -440,7 +440,7 @@ func (c *Connection) handleFTPUploadToExistingFile(fs vfs.Fs, flags int, resolve if common.Config.IsAtomicUploadEnabled() && fs.IsAtomicUploadSupported() { err = fs.Rename(resolvedPath, filePath) if err != nil { - c.Log(logger.LevelWarn, "error renaming existing file for atomic upload, source: %#v, dest: %#v, err: %+v", + c.Log(logger.LevelError, "error renaming existing file for atomic upload, source: %#v, dest: %#v, err: %+v", resolvedPath, filePath, err) return nil, c.GetFsError(fs, err) } @@ -448,7 +448,7 @@ func (c *Connection) handleFTPUploadToExistingFile(fs vfs.Fs, flags int, resolve file, w, cancelFn, err := fs.Create(filePath, flags) if err != nil { - c.Log(logger.LevelWarn, "error opening existing file, flags: %v, source: %#v, err: %+v", flags, filePath, err) + c.Log(logger.LevelError, "error opening existing file, flags: %v, source: %#v, err: %+v", flags, filePath, err) return nil, c.GetFsError(fs, err) } diff --git a/httpd/api_http_user.go b/httpd/api_http_user.go index a7408459..e7ed4c47 100644 --- a/httpd/api_http_user.go +++ b/httpd/api_http_user.go @@ -355,7 +355,7 @@ func deleteUserFile(w http.ResponseWriter, r *http.Request) { var fi os.FileInfo if fi, err = fs.Lstat(p); err != nil { - connection.Log(logger.LevelWarn, "failed to remove file %#v: stat error: %+v", p, err) + connection.Log(logger.LevelError, "failed to remove file %#v: stat error: %+v", p, err) err = connection.GetFsError(fs, err) sendAPIResponse(w, r, err, fmt.Sprintf("Unable to delete file %#v", name), getMappedStatusCode(err)) return diff --git a/httpd/api_utils.go b/httpd/api_utils.go index 20bfa5e3..8c404b18 100644 --- a/httpd/api_utils.go +++ b/httpd/api_utils.go @@ -198,7 +198,7 @@ func renderCompressedFiles(w http.ResponseWriter, conn *Connection, baseDir stri } } if err := wr.Close(); err != nil { - conn.Log(logger.LevelWarn, "unable to close zip file: %v", err) + conn.Log(logger.LevelError, "unable to close zip file: %v", err) if share != nil { dataprovider.UpdateShareLastUse(share, -1) //nolint:errcheck } diff --git a/httpd/handler.go b/httpd/handler.go index acd60253..c03eeee2 100644 --- a/httpd/handler.go +++ b/httpd/handler.go @@ -109,7 +109,7 @@ func (c *Connection) getFileReader(name string, offset int64, method string) (io file, r, cancelFn, err := fs.Open(p, offset) if err != nil { - c.Log(logger.LevelWarn, "could not open file %#v for reading: %+v", p, err) + c.Log(logger.LevelError, "could not open file %#v for reading: %+v", p, err) return nil, c.GetFsError(fs, err) } @@ -150,7 +150,7 @@ func (c *Connection) getFileWriter(name string) (io.WriteCloser, error) { // This happen if we upload a file that has the same name of an existing directory if stat.IsDir() { - c.Log(logger.LevelWarn, "attempted to open a directory for writing to: %#v", p) + c.Log(logger.LevelError, "attempted to open a directory for writing to: %#v", p) return nil, c.GetOpUnsupportedError() } @@ -161,7 +161,7 @@ func (c *Connection) getFileWriter(name string) (io.WriteCloser, error) { if common.Config.IsAtomicUploadEnabled() && fs.IsAtomicUploadSupported() { err = fs.Rename(p, filePath) if err != nil { - c.Log(logger.LevelWarn, "error renaming existing file for atomic upload, source: %#v, dest: %#v, err: %+v", + c.Log(logger.LevelError, "error renaming existing file for atomic upload, source: %#v, dest: %#v, err: %+v", p, filePath, err) return nil, c.GetFsError(fs, err) } @@ -186,7 +186,7 @@ func (c *Connection) handleUploadFile(fs vfs.Fs, resolvedPath, filePath, request file, w, cancelFn, err := fs.Create(filePath, 0) if err != nil { - c.Log(logger.LevelWarn, "error opening existing file, source: %#v, err: %+v", filePath, err) + c.Log(logger.LevelError, "error opening existing file, source: %#v, err: %+v", filePath, err) return nil, c.GetFsError(fs, err) } diff --git a/sftpd/handler.go b/sftpd/handler.go index 5c0d10dd..c92edfb4 100644 --- a/sftpd/handler.go +++ b/sftpd/handler.go @@ -80,7 +80,7 @@ func (c *Connection) Fileread(request *sftp.Request) (io.ReaderAt, error) { file, r, cancelFn, err := fs.Open(p, 0) if err != nil { - c.Log(logger.LevelWarn, "could not open file %#v for reading: %+v", p, err) + c.Log(logger.LevelError, "could not open file %#v for reading: %+v", p, err) return nil, c.GetFsError(fs, err) } @@ -146,7 +146,7 @@ func (c *Connection) handleFilewrite(request *sftp.Request) (sftp.WriterAtReader // This happen if we upload a file that has the same name of an existing directory if stat.IsDir() { - c.Log(logger.LevelWarn, "attempted to open a directory for writing to: %#v", p) + c.Log(logger.LevelError, "attempted to open a directory for writing to: %#v", p) return nil, sftp.ErrSSHFxOpUnsupported } @@ -356,7 +356,7 @@ func (c *Connection) handleSFTPUploadToNewFile(fs vfs.Fs, resolvedPath, filePath file, w, cancelFn, err := fs.Create(filePath, 0) if err != nil { - c.Log(logger.LevelWarn, "error creating file %#v: %+v", resolvedPath, err) + c.Log(logger.LevelError, "error creating file %#v: %+v", resolvedPath, err) return nil, c.GetFsError(fs, err) } @@ -404,7 +404,7 @@ func (c *Connection) handleSFTPUploadToExistingFile(fs vfs.Fs, pflags sftp.FileO if common.Config.IsAtomicUploadEnabled() && fs.IsAtomicUploadSupported() { err = fs.Rename(resolvedPath, filePath) if err != nil { - c.Log(logger.LevelWarn, "error renaming existing file for atomic upload, source: %#v, dest: %#v, err: %+v", + c.Log(logger.LevelError, "error renaming existing file for atomic upload, source: %#v, dest: %#v, err: %+v", resolvedPath, filePath, err) return nil, c.GetFsError(fs, err) } @@ -412,7 +412,7 @@ func (c *Connection) handleSFTPUploadToExistingFile(fs vfs.Fs, pflags sftp.FileO file, w, cancelFn, err := fs.Create(filePath, osFlags) if err != nil { - c.Log(logger.LevelWarn, "error opening existing file, flags: %v, source: %#v, err: %+v", pflags, filePath, err) + c.Log(logger.LevelError, "error opening existing file, flags: %v, source: %#v, err: %+v", pflags, filePath, err) return nil, c.GetFsError(fs, err) } diff --git a/sftpd/scp.go b/sftpd/scp.go index 1088f7fb..f1b4957e 100644 --- a/sftpd/scp.go +++ b/sftpd/scp.go @@ -78,7 +78,7 @@ func (c *scpCommand) handleRecursiveUpload() error { for { fs, err := c.connection.User.GetFilesystemForPath(destPath, c.connection.ID) if err != nil { - c.connection.Log(logger.LevelWarn, "error uploading file %#v: %+v", destPath, err) + c.connection.Log(logger.LevelError, "error uploading file %#v: %+v", destPath, err) c.sendErrorMessage(nil, fmt.Errorf("unable to get fs for path %#v", destPath)) return err } @@ -110,7 +110,7 @@ func (c *scpCommand) handleRecursiveUpload() error { destPath = path.Join(destPath, name) fs, err = c.connection.User.GetFilesystemForPath(destPath, c.connection.ID) if err != nil { - c.connection.Log(logger.LevelWarn, "error uploading file %#v: %+v", destPath, err) + c.connection.Log(logger.LevelError, "error uploading file %#v: %+v", destPath, err) c.sendErrorMessage(nil, fmt.Errorf("unable to get fs for path %#v", destPath)) return err } @@ -138,12 +138,12 @@ func (c *scpCommand) handleCreateDir(fs vfs.Fs, dirPath string) error { p, err := fs.ResolvePath(dirPath) if err != nil { - c.connection.Log(logger.LevelWarn, "error creating dir: %#v, invalid file path, err: %v", dirPath, err) + c.connection.Log(logger.LevelError, "error creating dir: %#v, invalid file path, err: %v", dirPath, err) c.sendErrorMessage(fs, err) return err } if !c.connection.User.HasPerm(dataprovider.PermCreateDirs, path.Dir(dirPath)) { - c.connection.Log(logger.LevelWarn, "error creating dir: %#v, permission denied", dirPath) + c.connection.Log(logger.LevelError, "error creating dir: %#v, permission denied", dirPath) c.sendErrorMessage(fs, common.ErrPermissionDenied) return common.ErrPermissionDenied } @@ -215,7 +215,7 @@ func (c *scpCommand) handleUploadFile(fs vfs.Fs, resolvedPath, filePath string, quotaResult := c.connection.HasSpace(isNewFile, false, requestPath) if !quotaResult.HasSpace { err := fmt.Errorf("denying file write due to quota limits") - c.connection.Log(logger.LevelWarn, "error uploading file: %#v, err: %v", filePath, err) + c.connection.Log(logger.LevelError, "error uploading file: %#v, err: %v", filePath, err) c.sendErrorMessage(fs, err) return err } @@ -271,7 +271,7 @@ func (c *scpCommand) handleUpload(uploadFilePath string, sizeToRead int64) error fs, p, err := c.connection.GetFsAndResolvedPath(uploadFilePath) if err != nil { - c.connection.Log(logger.LevelWarn, "error uploading file: %#v, err: %v", uploadFilePath, err) + c.connection.Log(logger.LevelError, "error uploading file: %#v, err: %v", uploadFilePath, err) c.sendErrorMessage(nil, err) return err } @@ -303,7 +303,7 @@ func (c *scpCommand) handleUpload(uploadFilePath string, sizeToRead int64) error } if stat.IsDir() { - c.connection.Log(logger.LevelWarn, "attempted to open a directory for writing to: %#v", p) + c.connection.Log(logger.LevelError, "attempted to open a directory for writing to: %#v", p) err = fmt.Errorf("attempted to open a directory for writing: %#v", p) c.sendErrorMessage(fs, err) return err @@ -473,7 +473,7 @@ func (c *scpCommand) handleDownload(filePath string) error { fs, err := c.connection.User.GetFilesystemForPath(filePath, c.connection.ID) if err != nil { - c.connection.Log(logger.LevelWarn, "error downloading file %#v: %+v", filePath, err) + c.connection.Log(logger.LevelError, "error downloading file %#v: %+v", filePath, err) c.sendErrorMessage(nil, fmt.Errorf("unable to get fs for path %#v", filePath)) return err } @@ -481,14 +481,14 @@ func (c *scpCommand) handleDownload(filePath string) error { p, err := fs.ResolvePath(filePath) if err != nil { err := fmt.Errorf("invalid file path %#v", filePath) - c.connection.Log(logger.LevelWarn, "error downloading file: %#v, invalid file path", filePath) + c.connection.Log(logger.LevelError, "error downloading file: %#v, invalid file path", filePath) c.sendErrorMessage(fs, err) return err } var stat os.FileInfo if stat, err = fs.Stat(p); err != nil { - c.connection.Log(logger.LevelWarn, "error downloading file: %#v->%#v, err: %v", filePath, p, err) + c.connection.Log(logger.LevelError, "error downloading file: %#v->%#v, err: %v", filePath, p, err) c.sendErrorMessage(fs, err) return err } @@ -636,7 +636,7 @@ func (c *scpCommand) sendConfirmationMessage() error { func (c *scpCommand) sendProtocolMessage(message string) error { _, err := c.connection.channel.Write([]byte(message)) if err != nil { - c.connection.Log(logger.LevelWarn, "error sending protocol message: %v, err: %v", message, err) + c.connection.Log(logger.LevelError, "error sending protocol message: %v, err: %v", message, err) c.connection.channel.Close() } return err @@ -686,7 +686,7 @@ func (c *scpCommand) parseUploadMessage(fs vfs.Fs, command string) (int64, strin if !strings.HasPrefix(command, "C") && !strings.HasPrefix(command, "D") { err = fmt.Errorf("unknown or invalid upload message: %v args: %v user: %v", command, c.args, c.connection.User.Username) - c.connection.Log(logger.LevelWarn, "error: %v", err) + c.connection.Log(logger.LevelError, "error: %v", err) c.sendErrorMessage(fs, err) return size, name, err } @@ -694,20 +694,20 @@ func (c *scpCommand) parseUploadMessage(fs vfs.Fs, command string) (int64, strin if len(parts) == 3 { size, err = strconv.ParseInt(parts[1], 10, 64) if err != nil { - c.connection.Log(logger.LevelWarn, "error getting size from upload message: %v", err) + c.connection.Log(logger.LevelError, "error getting size from upload message: %v", err) c.sendErrorMessage(fs, err) return size, name, err } name = parts[2] if name == "" { err = fmt.Errorf("error getting name from upload message, cannot be empty") - c.connection.Log(logger.LevelWarn, "error: %v", err) + c.connection.Log(logger.LevelError, "error: %v", err) c.sendErrorMessage(fs, err) return size, name, err } } else { err = fmt.Errorf("unable to split upload message: %#v", command) - c.connection.Log(logger.LevelWarn, "error: %v", err) + c.connection.Log(logger.LevelError, "error: %v", err) c.sendErrorMessage(fs, err) return size, name, err } diff --git a/sftpd/server.go b/sftpd/server.go index 81552ecd..52dcc0d0 100644 --- a/sftpd/server.go +++ b/sftpd/server.go @@ -498,7 +498,7 @@ func (c *Configuration) handleSftpConnection(channel ssh.Channel, connection *Co _, err = channel.SendRequest("exit-status", false, ssh.Marshal(&exitStatus)) connection.Log(logger.LevelInfo, "connection closed, sent exit status %+v error: %v", exitStatus, err) } else if err != nil { - connection.Log(logger.LevelWarn, "connection closed with error: %v", err) + connection.Log(logger.LevelError, "connection closed with error: %v", err) } } diff --git a/sftpd/ssh_cmd.go b/sftpd/ssh_cmd.go index 035030fe..e5f53c94 100644 --- a/sftpd/ssh_cmd.go +++ b/sftpd/ssh_cmd.go @@ -85,7 +85,7 @@ func processSSHCommand(payload []byte, connection *Connection, enabledSSHCommand } } err := connection.CloseFS() - connection.Log(logger.LevelWarn, "unable to unmarshal ssh command, close fs, err: %v", err) + connection.Log(logger.LevelError, "unable to unmarshal ssh command, close fs, err: %v", err) return false } @@ -727,7 +727,7 @@ func (c *sshCommand) sendExitStatus(err error) { } if err != nil { status = uint32(1) - c.connection.Log(logger.LevelWarn, "command failed: %#v args: %v user: %v err: %v", + c.connection.Log(logger.LevelError, "command failed: %#v args: %v user: %v err: %v", c.command, c.args, c.connection.User.Username, err) } exitStatus := sshSubsystemExitStatus{ diff --git a/vfs/osfs.go b/vfs/osfs.go index 37fd6648..374edd4c 100644 --- a/vfs/osfs.go +++ b/vfs/osfs.go @@ -102,7 +102,7 @@ func (*OsFs) Create(name string, flag int) (File, *PipeWriter, func(), error) { func (fs *OsFs) Rename(source, target string) error { err := os.Rename(source, target) if err != nil && isCrossDeviceError(err) { - fsLog(fs, logger.LevelWarn, "cross device error detected while renaming %#v -> %#v. Trying a copy and remove, this could take a long time", + fsLog(fs, logger.LevelError, "cross device error detected while renaming %#v -> %#v. Trying a copy and remove, this could take a long time", source, target) err = fscopy.Copy(source, target, fscopy.Options{ OnSymlink: func(src string) fscopy.SymlinkAction { @@ -110,7 +110,7 @@ func (fs *OsFs) Rename(source, target string) error { }, }) if err != nil { - fsLog(fs, logger.LevelDebug, "cross device copy error: %v", err) + fsLog(fs, logger.LevelError, "cross device copy error: %v", err) return err } return os.RemoveAll(source) @@ -299,14 +299,14 @@ func (fs *OsFs) ResolvePath(virtualPath string) (string, error) { // path chain until we hit a directory that _does_ exist and can be validated. _, err = fs.findFirstExistingDir(r) if err != nil { - fsLog(fs, logger.LevelWarn, "error resolving non-existent path %#v", err) + fsLog(fs, logger.LevelError, "error resolving non-existent path %#v", err) } return r, err } err = fs.isSubDir(p) if err != nil { - fsLog(fs, logger.LevelWarn, "Invalid path resolution, dir %#v original path %#v resolved %#v err: %v", + fsLog(fs, logger.LevelError, "Invalid path resolution, dir %#v original path %#v resolved %#v err: %v", p, virtualPath, r, err) } return r, err @@ -358,7 +358,7 @@ func (fs *OsFs) findNonexistentDirs(filePath string) ([]string, error) { } err = fs.isSubDir(p) if err != nil { - fsLog(fs, logger.LevelWarn, "error finding non existing dir: %v", err) + fsLog(fs, logger.LevelError, "error finding non existing dir: %v", err) } return results, err } @@ -366,7 +366,7 @@ func (fs *OsFs) findNonexistentDirs(filePath string) ([]string, error) { func (fs *OsFs) findFirstExistingDir(path string) (string, error) { results, err := fs.findNonexistentDirs(path) if err != nil { - fsLog(fs, logger.LevelWarn, "unable to find non existent dirs: %v", err) + fsLog(fs, logger.LevelError, "unable to find non existent dirs: %v", err) return "", err } var parent string @@ -395,7 +395,7 @@ func (fs *OsFs) isSubDir(sub string) error { // fs.rootDir must exist and it is already a validated absolute path parent, err := filepath.EvalSymlinks(fs.rootDir) if err != nil { - fsLog(fs, logger.LevelWarn, "invalid root path %#v: %v", fs.rootDir, err) + fsLog(fs, logger.LevelError, "invalid root path %#v: %v", fs.rootDir, err) return err } if parent == sub { diff --git a/vfs/s3fs.go b/vfs/s3fs.go index 264d7602..e9c09f1a 100644 --- a/vfs/s3fs.go +++ b/vfs/s3fs.go @@ -604,7 +604,7 @@ func (fs *S3Fs) getFileNamesInPrefix(fsPrefix string) (map[string]bool, error) { }) metric.S3ListObjectsCompleted(err) if err != nil { - fsLog(fs, logger.LevelWarn, "unable to get content for prefix %#v: %v", prefix, err) + fsLog(fs, logger.LevelError, "unable to get content for prefix %#v: %v", prefix, err) return nil, err } return fileNames, err diff --git a/vfs/sftpfs.go b/vfs/sftpfs.go index 5f386809..3caee526 100644 --- a/vfs/sftpfs.go +++ b/vfs/sftpfs.go @@ -547,7 +547,7 @@ func (fs *SFTPFs) ResolvePath(virtualPath string) (string, error) { var err error validatedPath, err = fs.getRealPath(fsPath) if err != nil && !os.IsNotExist(err) { - fsLog(fs, logger.LevelWarn, "Invalid path resolution, original path %v resolved %#v err: %v", + fsLog(fs, logger.LevelError, "Invalid path resolution, original path %v resolved %#v err: %v", virtualPath, fsPath, err) return "", err } else if os.IsNotExist(err) { @@ -560,13 +560,13 @@ func (fs *SFTPFs) ResolvePath(virtualPath string) (string, error) { validatedPath, err = fs.getRealPath(validatedPath) } if err != nil { - fsLog(fs, logger.LevelWarn, "Invalid path resolution, dir %#v original path %#v resolved %#v err: %v", + fsLog(fs, logger.LevelError, "Invalid path resolution, dir %#v original path %#v resolved %#v err: %v", validatedPath, virtualPath, fsPath, err) return "", err } } if err := fs.isSubDir(validatedPath); err != nil { - fsLog(fs, logger.LevelWarn, "Invalid path resolution, dir %#v original path %#v resolved %#v err: %v", + fsLog(fs, logger.LevelError, "Invalid path resolution, dir %#v original path %#v resolved %#v err: %v", validatedPath, virtualPath, fsPath, err) return "", err } @@ -727,7 +727,7 @@ func (fs *SFTPFs) createConnection() error { fp := ssh.FingerprintSHA256(key) if util.IsStringInSlice(fp, sftpFingerprints) { if util.IsStringInSlice(fs.config.Username, fs.config.forbiddenSelfUsernames) { - fsLog(fs, logger.LevelWarn, "SFTP loop or nested local SFTP folders detected, mount path %#v, username %#v, forbidden usernames: %+v", + fsLog(fs, logger.LevelError, "SFTP loop or nested local SFTP folders detected, mount path %#v, username %#v, forbidden usernames: %+v", fs.mountPath, fs.config.Username, fs.config.forbiddenSelfUsernames) return ErrSFTPLoop } diff --git a/webdavd/handler.go b/webdavd/handler.go index 68ee50c4..1fd6844b 100644 --- a/webdavd/handler.go +++ b/webdavd/handler.go @@ -145,7 +145,7 @@ func (c *Connection) getFile(fs vfs.Fs, fsPath, virtualPath string) (webdav.File if vfs.IsLocalOrUnbufferedSFTPFs(fs) { file, r, cancelFn, err = fs.Open(fsPath, 0) if err != nil { - c.Log(logger.LevelWarn, "could not open file %#v for reading: %+v", fsPath, err) + c.Log(logger.LevelError, "could not open file %#v for reading: %+v", fsPath, err) return nil, c.GetFsError(fs, err) } } @@ -182,7 +182,7 @@ func (c *Connection) putFile(fs vfs.Fs, fsPath, virtualPath string) (webdav.File // This happen if we upload a file that has the same name of an existing directory if stat.IsDir() { - c.Log(logger.LevelWarn, "attempted to open a directory for writing to: %#v", fsPath) + c.Log(logger.LevelError, "attempted to open a directory for writing to: %#v", fsPath) return nil, c.GetOpUnsupportedError() } @@ -205,7 +205,7 @@ func (c *Connection) handleUploadToNewFile(fs vfs.Fs, resolvedPath, filePath, re } file, w, cancelFn, err := fs.Create(filePath, 0) if err != nil { - c.Log(logger.LevelWarn, "error creating file %#v: %+v", resolvedPath, err) + c.Log(logger.LevelError, "error creating file %#v: %+v", resolvedPath, err) return nil, c.GetFsError(fs, err) } @@ -241,7 +241,7 @@ func (c *Connection) handleUploadToExistingFile(fs vfs.Fs, resolvedPath, filePat if common.Config.IsAtomicUploadEnabled() && fs.IsAtomicUploadSupported() { err = fs.Rename(resolvedPath, filePath) if err != nil { - c.Log(logger.LevelWarn, "error renaming existing file for atomic upload, source: %#v, dest: %#v, err: %+v", + c.Log(logger.LevelError, "error renaming existing file for atomic upload, source: %#v, dest: %#v, err: %+v", resolvedPath, filePath, err) return nil, c.GetFsError(fs, err) } @@ -249,7 +249,7 @@ func (c *Connection) handleUploadToExistingFile(fs vfs.Fs, resolvedPath, filePat file, w, cancelFn, err := fs.Create(filePath, 0) if err != nil { - c.Log(logger.LevelWarn, "error creating file %#v: %+v", resolvedPath, err) + c.Log(logger.LevelError, "error creating file %#v: %+v", resolvedPath, err) return nil, c.GetFsError(fs, err) } initialSize := int64(0) @@ -320,7 +320,7 @@ func (c *Connection) removeDirTree(fs vfs.Fs, fsPath, virtualPath string) error return nil }) if err != nil { - c.Log(logger.LevelWarn, "failed to remove dir tree %#v->%#v: error: %+v", virtualPath, fsPath, err) + c.Log(logger.LevelError, "failed to remove dir tree %#v->%#v: error: %+v", virtualPath, fsPath, err) return err }