mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API Apply logging to config cache
This commit is contained in:
parent
e4daf70b27
commit
8f0f9fa119
@ -2,6 +2,10 @@
|
||||
|
||||
namespace SilverStripe\Core\Config;
|
||||
|
||||
use Monolog\Handler\ErrorLogHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use SilverStripe\Config\Collections\CachedConfigCollection;
|
||||
use SilverStripe\Config\Collections\MemoryConfigCollection;
|
||||
use SilverStripe\Config\Transformer\PrivateStaticTransformer;
|
||||
@ -48,7 +52,7 @@ class CoreConfigFactory
|
||||
$instance = new CachedConfigCollection();
|
||||
|
||||
// Set root cache
|
||||
$instance->setPool(new FilesystemAdapter('configcache', 0, getTempFolder()));
|
||||
$instance->setPool($this->createPool());
|
||||
$instance->setFlush($flush);
|
||||
|
||||
// Set collection creator
|
||||
@ -168,4 +172,32 @@ class CoreConfigFactory
|
||||
return ModuleLoader::instance()->getManifest()->moduleExists($module);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Refactor bootstrapping of manifest caching into app object
|
||||
* @return FilesystemAdapter
|
||||
*/
|
||||
protected function createPool()
|
||||
{
|
||||
$cache = new FilesystemAdapter('configcache', 0, getTempFolder());
|
||||
$cache->setLogger($this->createLogger());
|
||||
return $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default error logger
|
||||
*
|
||||
* @todo Refactor bootstrapping of manifest logging into app object
|
||||
* @return LoggerInterface
|
||||
*/
|
||||
protected function createLogger()
|
||||
{
|
||||
$logger = new Logger("configcache-log");
|
||||
if (Director::isDev()) {
|
||||
$logger->pushHandler(new StreamHandler('php://output'));
|
||||
} else {
|
||||
$logger->pushHandler(new ErrorLogHandler());
|
||||
}
|
||||
return $logger;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user