3737use OCP \Diagnostics \IEventLogger ;
3838use OCP \ICacheFactory ;
3939use OCP \IDBConnection ;
40+ use OCP \ILogger ;
4041use OCP \IRequestId ;
4142use OCP \PreConditionNotMetException ;
4243use OCP \Profiler \IProfiler ;
@@ -818,7 +819,20 @@ public function commit() {
818819 $ this ->transactionBacktrace = null ;
819820 $ this ->transactionActiveSince = null ;
820821 if ($ timeTook > 1 ) {
821- $ this ->logger ->debug ('Transaction took ' . $ timeTook . 's ' , ['exception ' => new \Exception ('Transaction took ' . $ timeTook . 's ' )]);
822+ $ logLevel = match (true ) {
823+ $ timeTook > 20 * 60 => ILogger::ERROR ,
824+ $ timeTook > 5 * 60 => ILogger::WARN ,
825+ $ timeTook > 10 => ILogger::INFO ,
826+ default => ILogger::DEBUG ,
827+ };
828+ $ this ->logger ->log (
829+ $ logLevel ,
830+ 'Transaction took ' . $ timeTook . 's ' ,
831+ [
832+ 'exception ' => new \Exception ('Transaction took ' . $ timeTook . 's ' ),
833+ 'timeSpent ' => $ timeTook ,
834+ ]
835+ );
822836 }
823837 }
824838 return $ result ;
@@ -831,7 +845,20 @@ public function rollBack() {
831845 $ this ->transactionBacktrace = null ;
832846 $ this ->transactionActiveSince = null ;
833847 if ($ timeTook > 1 ) {
834- $ this ->logger ->debug ('Transaction rollback took longer than 1s: ' . $ timeTook , ['exception ' => new \Exception ('Long running transaction rollback ' )]);
848+ $ logLevel = match (true ) {
849+ $ timeTook > 20 * 60 => ILogger::ERROR ,
850+ $ timeTook > 5 * 60 => ILogger::WARN ,
851+ $ timeTook > 10 => ILogger::INFO ,
852+ default => ILogger::DEBUG ,
853+ };
854+ $ this ->logger ->log (
855+ $ logLevel ,
856+ 'Transaction rollback took longer than 1s: ' . $ timeTook ,
857+ [
858+ 'exception ' => new \Exception ('Long running transaction rollback ' ),
859+ 'timeSpent ' => $ timeTook ,
860+ ]
861+ );
835862 }
836863 }
837864 return $ result ;
0 commit comments