本文整理汇总了PHP中Thelia\Log\Tlog::getNewInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Tlog::getNewInstance方法的具体用法?PHP Tlog::getNewInstance怎么用?PHP Tlog::getNewInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Log\Tlog
的用法示例。
在下文中一共展示了Tlog::getNewInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLog
/**
* Initialize a module-specific logger.
*
* @return Tlog a Tlog instance
*/
protected function getLog()
{
if ($this->log == null) {
$this->log = Tlog::getNewInstance();
$logFilePath = sprintf(THELIA_ROOT . "log" . DS . "%s.log", strtolower($this->getModuleCode()));
$this->log->setPrefix("#LEVEL: #DATE #HOUR: ");
$this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile");
$this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath);
}
return $this->log;
}
示例2: getLogger
/**
* Returns the module-specific logger, initializing it if required.
*
* @return Tlog a Tlog instance
*/
public function getLogger()
{
if ($this->log == null) {
$this->log = Tlog::getNewInstance();
$logFilePath = $this->getLogFilePath();
$this->log->setPrefix("#LEVEL: #DATE #HOUR: ");
$this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile");
$this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath);
}
return $this->log;
}
示例3: __construct
public function __construct()
{
$this->logger = Tlog::getNewInstance();
$this->logger->setDestinations(static::LOG_CLASS);
$this->logger->setConfig(self::LOG_CLASS, 0, THELIA_ROOT . "log" . DS . "log-shopping-flux.txt");
/**
* Create a fake user ShoppingFlux if it doesn't exist
*/
$this->shoppingFluxCustomer = ShoppingFluxConfigQuery::createShoppingFluxCustomer();
$this->shoppingFluxPaymentModule = (new ShoppingFlux())->getModuleModel();
$this->shoppingFluxPaymentModuleId = $this->shoppingFluxPaymentModule->getId();
}
示例4: setUp
public function setUp()
{
new Translator(new Container());
Tlog::getNewInstance();
$cacheDir = THELIA_CACHE_DIR . "test";
if (!is_dir($cacheDir)) {
mkdir($cacheDir);
}
$this->tar = $this->getArchiveBuilder();
if (!$this->tar->isAvailable()) {
$this->markTestSkipped("The " . $this->tar->getExtension() . " archiver can't be tested as its dependencies are not installed/configured in this context");
}
$this->tar->setEnvironment("test");
}
示例5: setUp
public function setUp()
{
new Translator(new Container());
Tlog::getNewInstance();
$cacheDir = THELIA_CACHE_DIR . "test";
if (!is_dir($cacheDir)) {
mkdir($cacheDir);
}
$this->zip = new ZipArchiveBuilder();
if (!$this->zip->isAvailable()) {
$this->markTestSkipped("The " . $this->zip->getExtension() . " archiver can't be tested as its dependencies are not installed/configured in this context");
}
$this->zip->setEnvironment("test");
$this->loadedZip = $this->zip->loadArchive(__DIR__ . DS . "TestResources/well_formatted.zip");
}
示例6: setUp
public function setUp()
{
$logger = Tlog::getNewInstance();
$translator = new Translator(new Container());
$this->downloader = new FileDownloader($logger, $translator);
}
示例7: __construct
public function __construct()
{
$this->translator = Translator::getInstance();
$this->logger = Tlog::getNewInstance();
}
示例8: setUp
public function setUp()
{
Tlog::getNewInstance();
$this->session = $this->getSession();
$this->container = $this->getContainer();
}
示例9: getExport
public function getExport($generateOnly = false)
{
$env = $this->container->getParameter("kernel.environment");
$theliaCacheDirectory = THELIA_CACHE_DIR . $env . DS;
$generateFile = true;
$writeCache = false;
/**
* Error logging tools
*/
$logger = Tlog::getNewInstance();
$logger->setDestinations(static::LOG_CLASS);
$logger->setConfig(self::LOG_CLASS, 0, THELIA_ROOT . "log" . DS . "log-shopping-flux.txt");
$translator = Translator::getInstance();
$cacheDirectory = $theliaCacheDirectory . static::SHOPPING_FLUX_CACHE_DIR . DS;
$cacheFile = $cacheDirectory . static::CACHE_FILE_NAME;
/**
* Check if the file exists, if it is readable and if
* we have to get the cache or save it.
*/
if (file_exists($cacheFile)) {
if (!is_readable($cacheFile)) {
$logger->warning($translator->trans("The file %file is not readable, the cache can't be used", ["%file" => $cacheFile], ShoppingFlux::MESSAGE_DOMAIN));
} else {
$time = @filemtime($cacheFile);
if (false === $time) {
$logger->error($translator->trans("Unknown error while getting %file update time", ["%file" => $cacheFile], ShoppingFlux::MESSAGE_DOMAIN));
} elseif ($time < ($limitTime = time() - static::CACHE_TIME_HOUR * 3600)) {
/**
* If the cache is too old
*/
if (!is_writable($cacheFile)) {
$logger->warning($translator->trans("The file %file is not writable, the cache can't be saved", ["%file" => $cacheFile], ShoppingFlux::MESSAGE_DOMAIN));
} else {
$writeCache = true;
}
} elseif ($time >= $limitTime) {
$generateFile = false;
}
}
} else {
/**
* Check if the cache directory exists,
* if not, create it.
*/
if (!file_exists($cacheDirectory)) {
if (!@mkdir($cacheDirectory)) {
$logger->warning($translator->trans("Unable to create the cache directory %dir", ["%dir" => $cacheDirectory], ShoppingFlux::MESSAGE_DOMAIN));
} else {
$writeCache = true;
}
}
}
if (is_file($cacheDirectory) && !unlink($cacheDirectory)) {
$logger->warning($translator->trans("Unable to create the cache directory, a file named %dir exists and can't be deleted", ["%dir" => $cacheDirectory], ShoppingFlux::MESSAGE_DOMAIN));
} elseif (is_dir($cacheDirectory)) {
if (!is_writable($cacheDirectory)) {
$logger->warning($translator->trans("The directory %dir is not writable, the cache file can't be saved", ["%dir" => $cacheDirectory], ShoppingFlux::MESSAGE_DOMAIN));
} elseif (!file_exists($cacheFile)) {
$writeCache = true;
}
}
/**
* Then when everything's ok ( directory created if not ) go.
*/
if ($generateFile) {
$content = ShoppingFluxConfigQuery::exportXML($this->container);
} elseif (!$generateOnly) {
$content = file_get_contents($cacheFile);
} else {
$content = null;
}
if ($writeCache && $content !== null) {
file_put_contents($cacheFile, $content);
}
if ($generateOnly) {
return !($generateFile ^ $writeCache) && is_writable($cacheFile);
}
return new Response($content, 200, ["Content-type" => "application/xml"]);
}