Skip to content

Commit

Permalink
Fix/improved remote store logging (#224)
Browse files Browse the repository at this point in the history
* - **CHANGED** Improved logging in remote store
* - **FIXED** splitURI handles mixed forward and backward slash better
* changelog
  • Loading branch information
DanEngelbrecht authored Aug 12, 2022
1 parent f00d07a commit 3e2dd05
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 28 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
##
- **CHANGED** commands now logs input details at info level
- **
- **CHANGED** commands now logs input details at `info` level
- **CHANGED** Improved logging in remotestore with `info` level
- **CHANGED** Stats output is now printed to StdOut and with formatted logging to log file if `--log-file-path` is enabled
- **CHANGED** All logging now goes through logrus with the default logrus text formatting
- **CHANGED** Progress output in console now goes to StdOut instead of StdErr
Expand All @@ -11,6 +13,7 @@
- **FIXED** Improved retrylogic when writing stored block with better logging details
- **FIXED** Full support for windows extended length paths (fixes: UNC path may not contain forward slashes (#214))
- **FIXED** Corrected some function names logging
- **FIXED** splitURI handles mixed forward and backward slash better
- **UPDATED** Updated longtail to 0.3.5

## v0.3.5
Expand Down
2 changes: 2 additions & 0 deletions longtailstorelib/blobStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type BlobObject interface {
// Will return an error if a version lock is set with LockWriteVersion()
// and the underlying file has changed
Delete() error

String() string
}

type BlobProperties struct {
Expand Down
10 changes: 7 additions & 3 deletions longtailstorelib/fsstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (blobStore *fsBlobStore) NewClient(ctx context.Context) (BlobClient, error)
}

func (blobStore *fsBlobStore) String() string {
return fmt.Sprintf("fsstore %s", blobStore.prefix)
return fmt.Sprintf("fsblob://%s", blobStore.prefix)
}

func (blobClient *fsBlobClient) NewObject(filepath string) (BlobObject, error) {
Expand Down Expand Up @@ -102,7 +102,7 @@ func (blobClient *fsBlobClient) Close() {
}

func (blobClient *fsBlobClient) String() string {
return fmt.Sprintf("%s:client", blobClient.store.String())
return blobClient.store.String()
}

func (blobObject *fsBlobObject) Exists() (bool, error) {
Expand Down Expand Up @@ -203,7 +203,7 @@ func (blobObject *fsBlobObject) LockWriteVersion() (bool, error) {
const fname = "fsBlobObject.LockWriteVersion"

if !blobObject.client.store.enableLocking {
err := fmt.Errorf("Locking is not supported for %s", blobObject.client.store.String())
err := fmt.Errorf("locking is not supported for %s", blobObject.String())
return false, errors.Wrap(err, fname)
}

Expand Down Expand Up @@ -311,6 +311,10 @@ func (blobObject *fsBlobObject) Delete() error {
return err
}

func (blobObject *fsBlobObject) String() string {
return fmt.Sprintf("%s/%s", blobObject.client.String(), blobObject.path)
}

// ErrTimeout indicates that the lock attempt timed out.
var ErrTimeout error = timeoutError("lock timeout exceeded")

Expand Down
4 changes: 4 additions & 0 deletions longtailstorelib/gcsstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,7 @@ func (blobObject *gcsBlobObject) Delete() error {
}
return nil
}

func (blobObject *gcsBlobObject) String() string {
return fmt.Sprintf("%s/%s", blobObject.client.String(), blobObject.path)
}
6 changes: 5 additions & 1 deletion longtailstorelib/memblobstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (blobClient *memBlobClient) Close() {
}

func (blobClient *memBlobClient) String() string {
return "memstore"
return blobClient.store.String()
}

func (blobObject *memBlobObject) Exists() (bool, error) {
Expand Down Expand Up @@ -154,3 +154,7 @@ func (blobObject *memBlobObject) Delete() error {
delete(blobObject.client.store.blobs, blobObject.path)
return nil
}

func (blobObject *memBlobObject) String() string {
return fmt.Sprintf("%s/%s", blobObject.client.String(), blobObject.path)
}
4 changes: 4 additions & 0 deletions longtailstorelib/s3Store.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,7 @@ func (blobObject *s3BlobObject) Delete() error {
}
return nil
}

func (blobObject *s3BlobObject) String() string {
return fmt.Sprintf("%s/%s", blobObject.client.String(), blobObject.path)
}
5 changes: 3 additions & 2 deletions longtailutils/longtailutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ func splitURI(uri string) (string, string) {
})
log.Debug(fname)
i := strings.LastIndex(uri, "/")
if i == -1 {
i = strings.LastIndex(uri, "\\")
backI := strings.LastIndex(uri, "\\")
if backI > i || i == -1 {
i = backI
}
if i == -1 {
return "", uri
Expand Down
Loading

0 comments on commit 3e2dd05

Please sign in to comment.