Skip to content

Commit

Permalink
Adds extensive state logging
Browse files Browse the repository at this point in the history
  • Loading branch information
crsib committed Apr 9, 2024
1 parent 3038304 commit 32d338e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libraries/lib-cloud-audiocom/sync/ProjectCloudExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include "Track.h"

#include <wx/log.h>

namespace audacity::cloud::audiocom::sync
{
namespace
Expand Down Expand Up @@ -524,8 +526,17 @@ void ProjectCloudExtension::Publish(
CloudStatusChangedMessage cloudStatus, bool canMerge)
{
{
auto lock = std::lock_guard { mStatusMutex };
auto lock = std::lock_guard { mStatusMutex };

mLastStatus = cloudStatus;

wxLogInfo(wxString::Format(
"Sync status %d %f", int(mLastStatus.Status), mLastStatus.Progress));

if (mLastStatus.Error.has_value())
wxLogInfo(wxString::Format(
"Sync error %d %s", int(mLastStatus.Error->Type),
mLastStatus.Error->ErrorMessage));
}

mAsyncStateNotifier->Enqueue(cloudStatus, canMerge);
Expand Down
15 changes: 15 additions & 0 deletions modules/mod-cloud-audiocom/CloudProjectFileIOExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include "ProjectFileManager.h"
#include "ProjectWindow.h"

#include <wx/log.h>

namespace
{
using namespace audacity::cloud::audiocom;
Expand Down Expand Up @@ -214,6 +216,9 @@ class IOExtension final : public ProjectFileIOExtension

const int savesCount = projectCloudExtension.GetSavesCount();

wxLogInfo(wxString::Format(
"Project %s saved %d times", project.GetProjectName(), savesCount));

if (savesCount > 1)
return;

Expand All @@ -227,15 +232,25 @@ class IOExtension final : public ProjectFileIOExtension
if (!project)
return true;

wxLogInfo(wxString::Format(
"Waiting for sync %s", project->GetProjectName()));

return !ProjectCloudExtension::Get(*project).IsSyncing();
},
[weakProject = project.weak_from_this()]
{
wxLogInfo("Predicate returned");

auto project = weakProject.lock();

if (!project)
return;

wxLogInfo(wxString::Format(
"Sync status %s: %d", project->GetProjectName(),
int(ProjectCloudExtension::Get(*project)
.GetCurrentSyncStatus())));

if (
ProjectCloudExtension::Get(*project).GetCurrentSyncStatus() !=
ProjectSyncStatus::Synced)
Expand Down

0 comments on commit 32d338e

Please sign in to comment.