@@ -171,11 +171,13 @@ CancellationToken token
171171 _syncMetrics . RepositoryBackupCreated = canRollbackParatext ;
172172 if ( canRollbackParatext )
173173 {
174- Log ( $ "RunAsync: There wasn't already a local PT repo backup, so we made one.") ;
174+ LogMetric ( $ "RunAsync: There wasn't already a local PT repo backup, so we made one.") ;
175175 }
176176 else
177177 {
178- Log ( $ "RunAsync: There wasn't already a local PT repo backup, so we tried to make one but failed.") ;
178+ LogMetric (
179+ $ "RunAsync: There wasn't already a local PT repo backup, so we tried to make one but failed."
180+ ) ;
179181 }
180182 }
181183
@@ -184,17 +186,17 @@ CancellationToken token
184186
185187 if ( _paratextService . IsResource ( targetParatextId ) )
186188 {
187- Log ( $ "This is a resource, so not considering hg repo revisions.") ;
189+ LogMetric ( $ "This is a resource, so not considering hg repo revisions.") ;
188190 }
189191 else if ( _projectDoc . Data . Sync . SyncedToRepositoryVersion == null )
190192 {
191- Log (
193+ LogMetric (
192194 $ "The SF DB SyncedToRepositoryVersion is null. Maybe this project is being Connected, or has not synced successfully since we started tracking this information."
193195 ) ;
194196 }
195197 else
196198 {
197- Log (
199+ LogMetric (
198200 $ "Setting hg repo to last imported hg repo rev of { _projectDoc . Data . Sync . SyncedToRepositoryVersion } ."
199201 ) ;
200202 _paratextService . SetRepoToRevision (
@@ -295,7 +297,7 @@ await GetAndUpdateParatextBooksAndNotes(
295297 // delete all data for removed books
296298 if ( targetBooksToDelete . Count > 0 )
297299 {
298- Log (
300+ LogMetric (
299301 $ "RunAsync: Going to delete texts and questions,comments,answers for { targetBooksToDelete . Count } books."
300302 ) ;
301303 // delete target books
@@ -889,7 +891,7 @@ private async Task PreflightAuthenticationReportAsync()
889891 {
890892 bool canAuthToRegistry = await _paratextService . CanUserAuthenticateToPTRegistryAsync ( _userSecret ) ;
891893 bool canAuthToArchives = await _paratextService . CanUserAuthenticateToPTArchivesAsync ( _userSecret . Id ) ;
892- Log ( $ "User can authenticate to PT Registry: { canAuthToRegistry } , to PT Archives: { canAuthToArchives } .") ;
894+ LogMetric ( $ "User can authenticate to PT Registry: { canAuthToRegistry } , to PT Archives: { canAuthToArchives } .") ;
893895 }
894896
895897 private async Task UpdateDocsAsync (
@@ -1688,11 +1690,11 @@ private async Task CompleteSync(bool successful, bool canRollbackParatext, Cance
16881690 await NotifySyncProgress ( SyncPhase . Phase9 , 60.0 ) ;
16891691 if ( token . IsCancellationRequested )
16901692 {
1691- Log ( $ "CompleteSync: There was a cancellation request.") ;
1693+ LogMetric ( $ "CompleteSync: There was a cancellation request.") ;
16921694 }
16931695 if ( _projectDoc == null || _projectSecret == null )
16941696 {
1695- Log ( "CompleteSync: _projectDoc or _projectSecret are null. Rolling back SF DB transaction." ) ;
1697+ LogMetric ( "CompleteSync: _projectDoc or _projectSecret are null. Rolling back SF DB transaction." ) ;
16961698 _conn . RollbackTransaction ( ) ;
16971699 return ;
16981700 }
@@ -1738,7 +1740,7 @@ private async Task CompleteSync(bool successful, bool canRollbackParatext, Cance
17381740 _syncMetrics . RepositoryRestoredFromBackup = restoreSucceeded ;
17391741 }
17401742 }
1741- Log (
1743+ LogMetric (
17421744 $ "CompleteSync: Sync was not successful. { ( restoreSucceeded ? "Rolled back" : "Failed to roll back" ) } local PT repo."
17431745 ) ;
17441746 if ( ! restoreSucceeded )
@@ -1757,15 +1759,15 @@ await _projectDoc.SubmitJson0OpAsync(op =>
17571759
17581760 if ( successful )
17591761 {
1760- Log ( $ "CompleteSync: Successfully synchronized to PT repo commit id '{ repoVersion } '.") ;
1762+ LogMetric ( $ "CompleteSync: Successfully synchronized to PT repo commit id '{ repoVersion } '.") ;
17611763 op . Set ( pd => pd . Sync . DateLastSuccessfulSync , DateTime . UtcNow ) ;
17621764 op . Set ( pd => pd . Sync . SyncedToRepositoryVersion , repoVersion ) ;
17631765 // If the sync was successful, then the last sync error code should be cleared
17641766 op . Unset ( pd => pd . Sync . LastSyncErrorCode ) ;
17651767 }
17661768 else
17671769 {
1768- Log (
1770+ LogMetric (
17691771 $ "CompleteSync: Failed to synchronize. PT repo latest shared version is '{ repoVersion } '. SF DB project SyncedToRepositoryVersion is '{ _projectDoc . Data . Sync . SyncedToRepositoryVersion } '."
17701772 ) ;
17711773 }
@@ -2061,7 +2063,7 @@ private void ReportRepoRevs(string prefix = "")
20612063 $ "DB Sync.SyncedToRepositoryVersion: { _projectDoc . Data . Sync . SyncedToRepositoryVersion } , DB Sync.DataInSync: { _projectDoc . Data . Sync . DataInSync } .";
20622064 if ( _paratextService . IsResource ( projectPTId ) )
20632065 {
2064- Log ( $ "{ prefix } In-sync info: Is resource. { dbInfo } ") ;
2066+ LogMetric ( $ "{ prefix } In-sync info: Is resource. { dbInfo } ") ;
20652067 }
20662068 else if ( ! _paratextService . LocalProjectDirExists ( projectPTId ) )
20672069 {
@@ -2071,7 +2073,7 @@ private void ReportRepoRevs(string prefix = "")
20712073 {
20722074 string repoRev = _paratextService . GetRepoRevision ( _userSecret , projectPTId ) ;
20732075 string sharedRev = _paratextService . GetLatestSharedVersion ( _userSecret , projectPTId ) ;
2074- Log (
2076+ LogMetric (
20752077 $ "{ prefix } In-sync info: Local hg repo current rev: { repoRev } , Latest shared rev: { sharedRev } , { dbInfo } "
20762078 ) ;
20772079 }
@@ -2197,5 +2199,5 @@ private void Log(string message, string? projectSFId = null, string? userId = nu
21972199 _syncMetrics ? . Log . Add ( $ "{ DateTime . UtcNow : u} { message } ") ;
21982200 }
21992201
2200- private void LogMetric ( string message ) => Log ( message ) ;
2202+ private void LogMetric ( string message ) => _syncMetrics ? . Log . Add ( $ " { DateTime . UtcNow : u } { message } " ) ;
22012203}
0 commit comments