6464use OCP \Files \NotFoundException ;
6565use OCP \Files \ReservedWordException ;
6666use OCP \Files \Storage \IStorage ;
67- use OCP \ILogger ;
6867use OCP \IUser ;
6968use OCP \Lock \ILockingProvider ;
7069use OCP \Lock \LockedException ;
70+ use Psr \Log \LoggerInterface ;
7171
7272/**
7373 * Class to provide access to ownCloud filesystem via a "view", and methods for
@@ -101,8 +101,7 @@ class View {
101101 /** @var \OC\User\Manager */
102102 private $ userManager ;
103103
104- /** @var \OCP\ILogger */
105- private $ logger ;
104+ private LoggerInterface $ logger ;
106105
107106 private DisplayNameCache $ displayNameCache ;
108107
@@ -123,7 +122,7 @@ public function __construct($root = '') {
123122 $ this ->lockingEnabled = !($ this ->lockingProvider instanceof \OC \Lock \NoopLockingProvider);
124123 $ this ->userManager = \OC ::$ server ->getUserManager ();
125124 $ this ->displayNameCache = \OC ::$ server ->get (DisplayNameCache::class);
126- $ this ->logger = \OC ::$ server ->getLogger ( );
125+ $ this ->logger = \OC ::$ server ->get (LoggerInterface::class );
127126 }
128127
129128 public function getAbsolutePath ($ path = '/ ' ) {
@@ -579,7 +578,7 @@ public function touch($path, $mtime = null) {
579578 try {
580579 $ result = $ this ->basicOperation ('touch ' , $ path , $ hooks , $ mtime );
581580 } catch (\Exception $ e ) {
582- $ this ->logger ->logException ( $ e , ['level ' => ILogger:: INFO , 'message ' => ' Error while setting modified time ' ]);
581+ $ this ->logger ->info ( ' Error while setting modified time ' , ['app ' => ' core ' , 'exception ' => $ e ]);
583582 $ result = false ;
584583 }
585584 if (!$ result ) {
@@ -1000,11 +999,11 @@ public function fopen($path, $mode) {
1000999 $ hooks [] = 'write ' ;
10011000 break ;
10021001 default :
1003- \ OCP \Util:: writeLog ( ' core ' , ' invalid mode ( ' . $ mode . ') for ' . $ path , ILogger:: ERROR );
1002+ $ this -> logger -> error ( ' invalid mode ( ' . $ mode . ') for ' . $ path , [ ' app ' => ' core ' ] );
10041003 }
10051004
10061005 if ($ mode !== 'r ' && $ mode !== 'w ' ) {
1007- \ OC :: $ server -> getLogger () ->info ('Trying to open a file with a mode other than "r" or "w" can cause severe performance issues with some backends ' );
1006+ $ this -> logger ->info ('Trying to open a file with a mode other than "r" or "w" can cause severe performance issues with some backends ' , [ ' app ' => ' core ' ] );
10081007 }
10091008
10101009 return $ this ->basicOperation ('fopen ' , $ path , $ hooks , $ mode );
@@ -1418,7 +1417,7 @@ public function getFileInfo($path, $includeMountPoints = true) {
14181417
14191418 return $ info ;
14201419 } else {
1421- \ OC :: $ server -> getLogger () ->warning ('Storage not valid for mountpoint: ' . $ mount ->getMountPoint ());
1420+ $ this -> logger ->warning ('Storage not valid for mountpoint: ' . $ mount ->getMountPoint (), [ ' app ' => ' core ' ] );
14221421 }
14231422
14241423 return false ;
@@ -1502,10 +1501,9 @@ public function getDirectoryContent($directory, $mimetype_filter = '', \OCP\File
15021501 continue ;
15031502 } catch (\Exception $ e ) {
15041503 // sometimes when the storage is not available it can be any exception
1505- \OC ::$ server ->getLogger ()->logException ($ e , [
1506- 'message ' => 'Exception while scanning storage " ' . $ subStorage ->getId () . '" ' ,
1507- 'level ' => ILogger::ERROR ,
1508- 'app ' => 'lib ' ,
1504+ $ this ->logger ->error ('Exception while scanning storage " ' . $ subStorage ->getId () . '" ' , [
1505+ 'exception ' => $ e ,
1506+ 'app ' => 'core ' ,
15091507 ]);
15101508 continue ;
15111509 }
@@ -1816,9 +1814,9 @@ private function targetIsNotShared(IStorage $targetStorage, string $targetIntern
18161814 );
18171815
18181816 if (count ($ shares ) > 0 ) {
1819- \ OCP \Util:: writeLog ( ' files ' ,
1817+ $ this -> logger -> debug (
18201818 'It is not allowed to move one mount point into a shared folder ' ,
1821- ILogger:: DEBUG );
1819+ [ ' app ' => ' files ' ] );
18221820 return false ;
18231821 }
18241822
@@ -2146,9 +2144,9 @@ public function getPathRelativeToFiles($absolutePath) {
21462144 // "$user", "files", "path/to/dir"
21472145 if (!isset ($ parts [1 ]) || $ parts [1 ] !== 'files ' ) {
21482146 $ this ->logger ->error (
2149- '$absolutePath must be relative to "files", value is "%s " ' ,
2147+ '$absolutePath must be relative to "files", value is "{absolutePath} " ' ,
21502148 [
2151- $ absolutePath
2149+ ' absolutePath ' => $ absolutePath,
21522150 ]
21532151 );
21542152 throw new \InvalidArgumentException ('$absolutePath must be relative to "files" ' );
0 commit comments