From 14962e2428c61dcb104ef604bdf25a8604801b03 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 28 Feb 2023 10:00:32 -0800 Subject: [PATCH] Logging Fixes / InitApp -> InitAppSettings --- app/app.go | 13 ++++++++++++- extensions/profile_value.go | 2 +- .../filesharing/filesharing_functionality.go | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/app.go b/app/app.go index 25f7592..6198d27 100644 --- a/app/app.go +++ b/app/app.go @@ -35,6 +35,16 @@ type application struct { settings *GlobalSettingsFile } +func (app *application) IsFeatureEnabled(experiment string) bool { + settings := app.ReadSettings() + if settings.ExperimentsEnabled { + if status, exists := settings.Experiments[experiment]; exists { + return status + } + } + return false +} + // Application is a full cwtch peer application. It allows management, usage and storage of multiple peers type Application interface { LoadProfiles(password string) @@ -56,6 +66,7 @@ type Application interface { ReadSettings() GlobalSettings UpdateSettings(settings GlobalSettings) + IsFeatureEnabled(experiment string) bool ShutdownPeer(string) Shutdown() @@ -67,7 +78,7 @@ type Application interface { // LoadProfileFn is the function signature for a function in an app that loads a profile type LoadProfileFn func(profile peer.CwtchPeer) -func InitApp(appDirectory string) *GlobalSettingsFile { +func LoadAppSettings(appDirectory string) *GlobalSettingsFile { log.Debugf("NewApp(%v)\n", appDirectory) os.MkdirAll(path.Join(appDirectory, "profiles"), 0700) diff --git a/extensions/profile_value.go b/extensions/profile_value.go index 5c4dddc..3855807 100644 --- a/extensions/profile_value.go +++ b/extensions/profile_value.go @@ -41,7 +41,7 @@ func (pne ProfileValueExtension) OnContactReceiveValue(profile peer.CwtchPeer, c // OnContactRequestValue for ProfileValueExtension handles returning Public Profile Values func (pne ProfileValueExtension) OnContactRequestValue(profile peer.CwtchPeer, conversation model.Conversation, eventID string, szp attr.ScopedZonedPath) { scope, zone, zpath := szp.GetScopeZonePath() - log.Infof("Looking up public | conversation scope/zone %v", szp.ToString()) + log.Debugf("Looking up public | conversation scope/zone %v", szp.ToString()) if scope.IsPublic() || scope.IsConversation() { val, exists := profile.GetScopedZonedAttribute(scope, zone, zpath) diff --git a/functionality/filesharing/filesharing_functionality.go b/functionality/filesharing/filesharing_functionality.go index 970d7c8..80a0346 100644 --- a/functionality/filesharing/filesharing_functionality.go +++ b/functionality/filesharing/filesharing_functionality.go @@ -181,7 +181,7 @@ func (om *OverlayMessage) ShouldAutoDL() bool { func (f *Functionality) VerifyOrResumeDownload(profile peer.CwtchPeer, conversation int, fileKey string) { if manifestFilePath, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.manifest", fileKey)); exists { if downloadfilepath, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.path", fileKey)); exists { - log.Infof("resuming %s", fileKey) + log.Debugf("resuming %s", fileKey) f.DownloadFile(profile, conversation, downloadfilepath, manifestFilePath, fileKey, files.MaxManifestSize*files.DefaultChunkSize) } else { log.Errorf("found manifest path but not download path for %s", fileKey) @@ -201,7 +201,7 @@ func (f *Functionality) CheckDownloadStatus(profile peer.CwtchPeer, fileKey stri event.TempFile: "", })) } else { - log.Infof("CheckDownloadStatus found .path but not .complete") + log.Debugf("CheckDownloadStatus found .path but not .complete") profile.PublishEvent(event.NewEvent(event.FileDownloadProgressUpdate, map[event.Field]string{ event.ProfileOnion: profile.GetOnion(), event.FileKey: fileKey,