88
99use OC \Log ;
1010use OC \SystemConfig ;
11- use OCP \AppFramework \QueryException ;
12- use OCP \IServerContainer ;
1311use OCP \Log \ILogFactory ;
1412use OCP \Log \IWriter ;
13+ use Psr \Container \ContainerExceptionInterface ;
14+ use Psr \Container \ContainerInterface ;
1515use Psr \Log \LoggerInterface ;
1616
1717class LogFactory implements ILogFactory {
1818 public function __construct (
19- private IServerContainer $ c ,
20- private SystemConfig $ systemConfig ,
19+ private readonly ContainerInterface $ c ,
20+ private readonly SystemConfig $ systemConfig ,
21+ private readonly string $ serverRoot ,
2122 ) {
2223 }
2324
2425 /**
25- * @throws QueryException
26+ * @throws ContainerExceptionInterface
2627 */
2728 #[\Override]
2829 public function get (string $ type ):IWriter {
2930 return match (strtolower ($ type )) {
3031 'errorlog ' => new Errorlog ($ this ->systemConfig ),
31- 'syslog ' => $ this ->c ->resolve (Syslog::class),
32- 'systemd ' => $ this ->c ->resolve (Systemdlog::class),
32+ 'syslog ' => $ this ->c ->get (Syslog::class),
33+ 'systemd ' => $ this ->c ->get (Systemdlog::class),
3334 'file ' => $ this ->buildLogFile (),
3435 default => $ this ->buildLogFile (),
3536 };
@@ -53,7 +54,7 @@ public function getCustomPsrLogger(string $path, string $type = 'file', string $
5354 }
5455
5556 protected function buildLogFile (string $ logFile = '' ): File {
56- $ defaultLogFile = $ this ->systemConfig ->getValue ('datadirectory ' , \ OC :: $ SERVERROOT . '/data ' ) . '/nextcloud.log ' ;
57+ $ defaultLogFile = $ this ->systemConfig ->getValue ('datadirectory ' , $ this -> serverRoot . '/data ' ) . '/nextcloud.log ' ;
5758 if ($ logFile === '' ) {
5859 $ logFile = $ this ->systemConfig ->getValue ('logfile ' , $ defaultLogFile );
5960 }
0 commit comments