66} from 'src/core/types/operation' ;
77import { db } from 'src/shared/database/client' ;
88import { delay } from 'src/shared/helpers/general' ;
9- import Log from 'src/shared/libraries/Log ' ;
9+ import { debug , error } from 'src/shared/libraries/log2 ' ;
1010import { type OperationModelStore } from '../modelRepo/OperationModelStore' ;
1111import { GroupComparisonType , type Operation } from '../operations/Operation' ;
1212import {
@@ -80,11 +80,11 @@ export class OperationRepo implements IOperationRepo, IStartableService {
8080 public _pause ( ) : void {
8181 clearInterval ( this . _timerID ) ;
8282 this . _timerID = undefined ;
83- Log . _debug ( 'OperationRepo: Paused' ) ;
83+ debug ( 'OperationRepo: Paused' ) ;
8484 }
8585
8686 public _enqueue ( operation : Operation ) : void {
87- Log . _debug ( `OperationRepo.enqueue(operation: ${ operation } )` ) ;
87+ debug ( `OperationRepo.enqueue(operation: ${ operation } )` ) ;
8888
8989 this . _internalEnqueue (
9090 {
@@ -97,7 +97,7 @@ export class OperationRepo implements IOperationRepo, IStartableService {
9797 }
9898
9999 public async _enqueueAndWait ( operation : Operation ) : Promise < void > {
100- Log . _debug ( `OperationRepo.enqueueAndWaitoperation: ${ operation } )` ) ;
100+ debug ( `OperationRepo.enqueueAndWaitoperation: ${ operation } )` ) ;
101101
102102 await new Promise < void > ( ( resolve , reject ) => {
103103 this . _internalEnqueue (
@@ -121,7 +121,7 @@ export class OperationRepo implements IOperationRepo, IStartableService {
121121 ( item ) => item . operation . _modelId === queueItem . operation . _modelId ,
122122 ) ;
123123 if ( hasExisting ) {
124- Log . _debug (
124+ debug (
125125 `OperationRepo: internalEnqueue - operation.modelId: ${ queueItem . operation . _modelId } already exists in the queue.` ,
126126 ) ;
127127 return ;
@@ -143,7 +143,7 @@ export class OperationRepo implements IOperationRepo, IStartableService {
143143 let runningOps = false ;
144144
145145 this . _timerID = setInterval ( async ( ) => {
146- if ( runningOps ) return Log . _debug ( 'Operations in progress' ) ;
146+ if ( runningOps ) return debug ( 'Operations in progress' ) ;
147147
148148 const ops = this . _getNextOps ( this . _executeBucket ) ;
149149
@@ -172,7 +172,7 @@ export class OperationRepo implements IOperationRepo, IStartableService {
172172 const response = await executor . _execute ( operations ) ;
173173 const idTranslations = response . _idTranslations ;
174174
175- Log . _debug ( `OperationRepo: execute response = ${ response . _result } ` ) ;
175+ debug ( `OperationRepo: execute response = ${ response . _result } ` ) ;
176176
177177 // Handle ID translations
178178 if ( idTranslations ) {
@@ -199,7 +199,7 @@ export class OperationRepo implements IOperationRepo, IStartableService {
199199 case ExecutionResult . _FailUnauthorized :
200200 case ExecutionResult . _FailNoretry :
201201 case ExecutionResult . _FailConflict :
202- Log . _error ( `Operation execution failed without retry: ${ operations } ` ) ;
202+ error ( `Operation execution failed without retry: ${ operations } ` ) ;
203203 ops . forEach ( ( op ) => {
204204 this . _operationModelStore . _remove ( op . operation . _modelId ) ;
205205 } ) ;
@@ -218,7 +218,7 @@ export class OperationRepo implements IOperationRepo, IStartableService {
218218 break ;
219219
220220 case ExecutionResult . _FailRetry :
221- Log . _error ( `Operation execution failed, retrying: ${ operations } ` ) ;
221+ error ( `Operation execution failed, retrying: ${ operations } ` ) ;
222222 // Add back all operations to front of queue
223223 [ ...ops ] . reverse ( ) . forEach ( ( op ) => {
224224 removeOpFromDB ( op . operation ) ;
@@ -231,7 +231,7 @@ export class OperationRepo implements IOperationRepo, IStartableService {
231231 break ;
232232
233233 case ExecutionResult . _FailPauseOpRepo :
234- Log . _error ( `Operation failed, pausing ops:${ operations } ` ) ;
234+ error ( `Operation failed, pausing ops:${ operations } ` ) ;
235235 this . _pause ( ) ;
236236 ops . forEach ( ( op ) => op . resolver ?.( false ) ) ;
237237 [ ...ops ] . reverse ( ) . forEach ( ( op ) => {
@@ -263,7 +263,7 @@ export class OperationRepo implements IOperationRepo, IStartableService {
263263 await delay ( OP_REPO_POST_CREATE_DELAY ) ;
264264 }
265265 } catch ( e ) {
266- Log . _error ( `Error attempting to execute operation: ${ ops } ` , e ) ;
266+ error ( `Error attempting to execute operation: ${ ops } ` , e ) ;
267267
268268 // On failure remove operations from store
269269 ops . forEach ( ( op ) => {
@@ -277,14 +277,14 @@ export class OperationRepo implements IOperationRepo, IStartableService {
277277 retries : number ,
278278 retryAfterSeconds ?: number ,
279279 ) : Promise < void > {
280- Log . _debug ( `retryAfterSeconds: ${ retryAfterSeconds } ` ) ;
280+ debug ( `retryAfterSeconds: ${ retryAfterSeconds } ` ) ;
281281 const retryAfterSecondsMs = ( retryAfterSeconds || 0 ) * 1000 ;
282282 const delayForOnRetries = retries * OP_REPO_DEFAULT_FAIL_RETRY_BACKOFF ;
283283 const delayFor = Math . max ( delayForOnRetries , retryAfterSecondsMs ) ;
284284
285285 if ( delayFor < 1 ) return ;
286286
287- Log . _error ( `Operations being delay for: ${ delayFor } ms` ) ;
287+ error ( `Operations being delay for: ${ delayFor } ms` ) ;
288288 await delay ( delayFor ) ;
289289 }
290290
0 commit comments