1010use League \Flysystem \Filesystem ;
1111use Neos \Flow \Annotations as Flow ;
1212use Neos \Flow \Exception ;
13+ use Neos \Flow \Log \PsrLoggerFactoryInterface ;
1314use Neos \Flow \ObjectManagement \ObjectManagerInterface ;
1415use Neos \Flow \Persistence \Doctrine \PersistenceManager ;
1516use Neos \Utility \Files ;
17+ use Psr \Log \LoggerInterface ;
1618
1719/**
1820 * @Flow\Scope(value="singleton")
@@ -45,6 +47,11 @@ class BackupService
4547 */
4648 protected $ persistenceManager ;
4749
50+ /**
51+ * @var LoggerInterface#
52+ */
53+ protected $ logger ;
54+
4855 public function __construct (ObjectManagerInterface $ objectManager )
4956 {
5057 $ this ->objectManager = $ objectManager ;
@@ -54,8 +61,12 @@ public function initializeObject()
5461 {
5562 $ this ->indexService = $ this ->objectManager ->get (BackupIndexService::class);
5663 $ this ->persistenceManager = $ this ->objectManager ->get (PersistenceManager::class);
64+
5765 $ filesystemFactory = $ this ->objectManager ->get (FilesystemFactory::class);
5866 $ this ->filesystem = $ filesystemFactory ->get ($ this ->config ['filesystem ' ]['type ' ]);
67+
68+ $ loggerFactory = $ this ->objectManager ->get (PsrLoggerFactoryInterface::class);
69+ $ this ->logger = $ loggerFactory ->get ('backupLogger ' );
5970 }
6071
6172 public function getBackups (int $ start = 0 , int $ limit = 0 ): array
@@ -76,6 +87,8 @@ public function deleteBackup(string $name): bool
7687 $ this ->filesystem ->delete ($ name );
7788 }
7889
90+ $ this ->logger ->info ('deleted backup ' .$ name );
91+
7992 return true ;
8093 }
8194
@@ -102,6 +115,7 @@ public function restoreBackup(string $name)
102115 }
103116 // persist all changes from the steps
104117 $ this ->persistenceManager ->persistAll ();
118+ $ this ->logger ->info ('restored backup ' .$ name );
105119 }
106120
107121
@@ -136,6 +150,7 @@ public function createBackup()
136150 Files::removeDirectoryRecursively ($ backupPath );
137151 // update index
138152 $ this ->indexService ->addBackup ($ backupName , new \DateTime (), $ meta );
153+ $ this ->logger ->info ('added backup ' .$ backupName );
139154 }
140155
141156 /**
0 commit comments