本文整理汇总了PHP中Pimcore\Logger类的典型用法代码示例。如果您正苦于以下问题:PHP Logger类的具体用法?PHP Logger怎么用?PHP Logger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* @param null $adapter
* @return null|Adapter\GD|Adapter\Imagick
* @throws \Exception
*/
public static function getInstance($adapter = null)
{
// use the default adapter if set manually (!= null) and no specify adapter is given
if (!$adapter && self::$defaultAdapter) {
$adapter = self::$defaultAdapter;
}
try {
if ($adapter) {
$adapterClass = "\\Pimcore\\Image\\Adapter\\" . $adapter;
if (Tool::classExists($adapterClass)) {
return new $adapterClass();
} else {
if (Tool::classExists($adapter)) {
return new $adapter();
} else {
throw new \Exception("Image-transform adapter `" . $adapter . "´ does not exist.");
}
}
} else {
if (extension_loaded("imagick")) {
return new Adapter\Imagick();
} else {
return new Adapter\GD();
}
}
} catch (\Exception $e) {
\Logger::crit("Unable to load image extensions: " . $e->getMessage());
throw $e;
}
return null;
}
示例2: tag
/**
* @param $type
* @param $realName
* @param array $options
* @return Model\Document\Tag
*/
public function tag($type, $realName, $options = array())
{
$type = strtolower($type);
$document = $this->document;
$name = Model\Document\Tag::buildTagName($type, $realName, $document);
try {
if ($document instanceof Model\Document\PageSnippet) {
$tag = $document->getElement($name);
if ($tag instanceof Model\Document\Tag && $tag->getType() == $type) {
// call the load() method if it exists to reinitialize the data (eg. from serializing, ...)
if (method_exists($tag, "load")) {
$tag->load();
}
// set view & controller, editmode
$tag->setController($this->controller);
$tag->setView($this);
$tag->setEditmode($this->editmode);
$tag->setOptions($options);
} else {
$tag = Model\Document\Tag::factory($type, $name, $document->getId(), $options, $this->controller, $this, $this->editmode);
$document->setElement($name, $tag);
}
// set the real name of this editable, without the prefixes and suffixes from blocks and areablocks
$tag->setRealName($realName);
}
return $tag;
} catch (\Exception $e) {
\Logger::warning($e);
}
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
// display error message
if (!$input->getOption("mode")) {
$this->writeError("Please specify the mode!");
exit;
}
$db = \Pimcore\Db::get();
if ($input->getOption("mode") == "optimize") {
$tables = $db->fetchAll("SHOW TABLES");
foreach ($tables as $table) {
$t = current($table);
try {
Logger::debug("Running: OPTIMIZE TABLE " . $t);
$db->query("OPTIMIZE TABLE " . $t);
} catch (\Exception $e) {
Logger::error($e);
}
}
} elseif ($input->getOption("mode") == "warmup") {
$tables = $db->fetchAll("SHOW TABLES");
foreach ($tables as $table) {
$t = current($table);
try {
Logger::debug("Running: SELECT COUNT(*) FROM {$t}");
$res = $db->fetchOne("SELECT COUNT(*) FROM {$t}");
Logger::debug("Result: " . $res);
} catch (\Exception $e) {
Logger::error($e);
}
}
}
}
示例4: stopCrawler
/**
* @static
* @return bool
*/
public static function stopCrawler()
{
\Pimcore\Logger::debug('LuceneSearch: forcing frontend crawler stop');
self::setStopLock('frontend', FALSE);
self::setCrawlerState('frontend', 'finished', FALSE);
return TRUE;
}
示例5: load
/**
* Loads a list of entries for the specicifies parameters, returns an array of Search\Backend\Data
*
* @return array
*/
public function load()
{
$entries = [];
$data = $this->db->fetchAll("SELECT * FROM search_backend_data" . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
foreach ($data as $entryData) {
if ($entryData['maintype'] == 'document') {
$element = Document::getById($entryData['id']);
} elseif ($entryData['maintype'] == 'asset') {
$element = Asset::getById($entryData['id']);
} elseif ($entryData['maintype'] == 'object') {
$element = Object::getById($entryData['id']);
} else {
Logger::err("unknown maintype ");
}
if ($element) {
$entry = new Search\Backend\Data();
$entry->setId(new Search\Backend\Data\Id($element));
$entry->setFullPath($entryData['fullpath']);
$entry->setType($entryData['type']);
$entry->setSubtype($entryData['subtype']);
$entry->setUserOwner($entryData['userowner']);
$entry->setUserModification($entryData['usermodification']);
$entry->setCreationDate($entryData['creationdate']);
$entry->setModificationDate($entryData['modificationdate']);
$entry->setPublished($entryData['published'] === 0 ? false : true);
$entries[] = $entry;
}
}
$this->model->setEntries($entries);
return $entries;
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$validJobs = [];
if ($input->getOption("job")) {
$validJobs = explode(",", $input->getOption("job"));
}
// create manager
$manager = Schedule\Manager\Factory::getManager("maintenance.pid");
$manager->setValidJobs($validJobs);
$manager->setForce((bool) $input->getOption("force"));
// register scheduled tasks
$manager->registerJob(new Schedule\Maintenance\Job("scheduledtasks", new Schedule\Task\Executor(), "execute"));
$manager->registerJob(new Schedule\Maintenance\Job("logmaintenance", new \Pimcore\Log\Maintenance(), "mail"));
$manager->registerJob(new Schedule\Maintenance\Job("cleanuplogfiles", new \Pimcore\Log\Maintenance(), "cleanupLogFiles"));
$manager->registerJob(new Schedule\Maintenance\Job("httperrorlog", new \Pimcore\Log\Maintenance(), "httpErrorLogCleanup"));
$manager->registerJob(new Schedule\Maintenance\Job("usagestatistics", new \Pimcore\Log\Maintenance(), "usageStatistics"));
$manager->registerJob(new Schedule\Maintenance\Job("checkErrorLogsDb", new \Pimcore\Log\Maintenance(), "checkErrorLogsDb"));
$manager->registerJob(new Schedule\Maintenance\Job("archiveLogEntries", new \Pimcore\Log\Maintenance(), "archiveLogEntries"));
$manager->registerJob(new Schedule\Maintenance\Job("sanitycheck", "\\Pimcore\\Model\\Element\\Service", "runSanityCheck"));
$manager->registerJob(new Schedule\Maintenance\Job("versioncleanup", new \Pimcore\Model\Version(), "maintenanceCleanUp"));
$manager->registerJob(new Schedule\Maintenance\Job("versioncompress", new \Pimcore\Model\Version(), "maintenanceCompress"));
$manager->registerJob(new Schedule\Maintenance\Job("redirectcleanup", "\\Pimcore\\Model\\Redirect", "maintenanceCleanUp"));
$manager->registerJob(new Schedule\Maintenance\Job("cleanupbrokenviews", "\\Pimcore\\Db", "cleanupBrokenViews"));
$manager->registerJob(new Schedule\Maintenance\Job("downloadmaxminddb", "\\Pimcore\\Update", "updateMaxmindDb"));
$manager->registerJob(new Schedule\Maintenance\Job("cleanupcache", "\\Pimcore\\Model\\Cache", "maintenance"));
$manager->registerJob(new Schedule\Maintenance\Job("tmpstorecleanup", "\\Pimcore\\Model\\Tool\\TmpStore", "cleanup"));
$manager->registerJob(new Schedule\Maintenance\Job("imageoptimize", "\\Pimcore\\Model\\Asset\\Image\\Thumbnail\\Processor", "processOptimizeQueue"));
\Pimcore::getEventManager()->trigger("system.maintenance", $manager);
$manager->run();
Logger::info("All maintenance-jobs finished!");
}
示例7: addPropertiesToDocument
/**
* @param Model\Document $document
* @throws \Zend_Json_Exception
*/
protected function addPropertiesToDocument(Model\Document $document)
{
// properties
if ($this->getParam("properties")) {
$properties = [];
// assign inherited properties
foreach ($document->getProperties() as $p) {
if ($p->isInherited()) {
$properties[$p->getName()] = $p;
}
}
$propertiesData = \Zend_Json::decode($this->getParam("properties"));
if (is_array($propertiesData)) {
foreach ($propertiesData as $propertyName => $propertyData) {
$value = $propertyData["data"];
try {
$property = new Property();
$property->setType($propertyData["type"]);
$property->setName($propertyName);
$property->setCtype("document");
$property->setDataFromEditmode($value);
$property->setInheritable($propertyData["inheritable"]);
$properties[$propertyName] = $property;
} catch (\Exception $e) {
Logger::warning("Can't add " . $propertyName . " to document " . $document->getRealFullPath());
}
}
}
if ($document->isAllowed("properties")) {
$document->setProperties($properties);
}
}
// force loading of properties
$document->getProperties();
}
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$status = ["success" => true];
$config = $input->getArgument("config");
if ($config) {
$job = json_decode($config, true);
if (is_array($job)) {
if (isset($job["dry-run"])) {
// do not do anything here
Logger::info("skipped update job because it is in dry-run mode", $job);
} elseif ($job["type"] == "files") {
Update::installData($job["revision"]);
} elseif ($job["type"] == "clearcache") {
\Pimcore\Cache::clearAll();
} elseif ($job["type"] == "preupdate") {
$status = Update::executeScript($job["revision"], "preupdate");
} elseif ($job["type"] == "postupdate") {
$status = Update::executeScript($job["revision"], "postupdate");
} elseif ($job["type"] == "cleanup") {
Update::cleanup();
}
}
}
$this->output->write(json_encode($status));
}
示例9: save
/**
* Save document to database
*
* @return void
*/
public function save()
{
$data = [];
$emailLog = get_object_vars($this->model);
foreach ($emailLog as $key => $value) {
if (in_array($key, $this->getValidTableColumns(self::$dbTable))) {
// check if the getter exists
$getter = "get" . ucfirst($key);
if (!method_exists($this->model, $getter)) {
continue;
}
// get the value from the getter
$value = $this->model->{$getter}();
if (is_bool($value)) {
$value = (int) $value;
} elseif (is_array($value)) {
//converts the dynamic params to a basic json string
$preparedData = self::createJsonLoggingObject($value);
$value = \Zend_Json::encode($preparedData);
}
$data[$key] = $value;
}
}
try {
$this->db->update(self::$dbTable, $data, $this->db->quoteInto("id = ?", $this->model->getId()));
} catch (\Exception $e) {
Logger::emerg('Could not Save emailLog with the id "' . $this->model->getId() . '" ');
}
}
示例10: reverseMap
/**
* @param $object
* @param bool $disableMappingExceptions
* @param null $idMapper
* @throws \Exception
*/
public function reverseMap($object, $disableMappingExceptions = false, $idMapper = null)
{
$keys = get_object_vars($this);
foreach ($keys as $key => $value) {
$method = "set" . $key;
if (method_exists($object, $method)) {
$object->{$method}($value);
}
}
//must be after generic setters above!!
parent::reverseMap($object, $disableMappingExceptions, $idMapper);
if (is_array($this->elements)) {
foreach ($this->elements as $element) {
$class = $object->getClass();
$setter = "set" . ucfirst($element->name);
if (method_exists($object, $setter)) {
$tag = $class->getFieldDefinition($element->name);
if ($tag) {
if ($class instanceof Model\Object\ClassDefinition\Data\Fieldcollections) {
$object->{$setter}($tag->getFromWebserviceImport($element->fieldcollection, $object, [], $idMapper));
} else {
$object->{$setter}($tag->getFromWebserviceImport($element->value, $object, [], $idMapper));
}
} else {
Logger::error("tag for field " . $element->name . " not found");
}
} else {
if (!$disableMappingExceptions) {
throw new \Exception("No element [ " . $element->name . " ] of type [ " . $element->type . " ] found in class definition [" . $class->getId() . "] | " . $class->getName());
}
}
}
}
}
示例11: saveAction
public function saveAction()
{
try {
if ($this->getParam("id")) {
$link = Document\Hardlink::getById($this->getParam("id"));
$this->setValuesToDocument($link);
$link->setModificationDate(time());
$link->setUserModification($this->getUser()->getId());
if ($this->getParam("task") == "unpublish") {
$link->setPublished(false);
}
if ($this->getParam("task") == "publish") {
$link->setPublished(true);
}
// only save when publish or unpublish
if ($this->getParam("task") == "publish" && $link->isAllowed("publish") || $this->getParam("task") == "unpublish" && $link->isAllowed("unpublish")) {
$link->save();
$this->_helper->json(["success" => true]);
}
}
} catch (\Exception $e) {
Logger::log($e);
if (\Pimcore\Tool\Admin::isExtJS6() && $e instanceof Element\ValidationException) {
$this->_helper->json(["success" => false, "type" => "ValidationException", "message" => $e->getMessage(), "stack" => $e->getTraceAsString(), "code" => $e->getCode()]);
}
throw $e;
}
$this->_helper->json(false);
}
示例12: delete
/**
* Deletes from database
*
* @return void
*/
public function delete()
{
if ($this->model->getId() instanceof Model\Search\Backend\Data\Id) {
$this->db->delete("search_backend_data", "id='" . $this->model->getId()->getId() . "' AND maintype ='" . $this->model->getId()->getType() . "'");
} else {
Logger::alert("Cannot delete Search\\Backend\\Data, ID is empty");
}
}
示例13: save
/**
*
*/
public function save()
{
try {
$this->db->insert("users_permission_definitions", ["key" => $this->model->getKey()]);
} catch (\Exception $e) {
Logger::warn($e);
}
}
示例14: setFilterPriority
/**
* @deprecated
* @param $level
*/
public function setFilterPriority($level)
{
// legacy ZF method
$zendLoggerPsr3Mapping = Logger::getZendLoggerPsr3Mapping();
if (isset($zendLoggerPsr3Mapping[$level])) {
$level = $zendLoggerPsr3Mapping[$level];
$this->setLevel($level);
}
}
示例15: _handleError
/**
* @param \Zend_Controller_Request_Abstract $request
* @throws mixed
*/
protected function _handleError(\Zend_Controller_Request_Abstract $request)
{
// remove zend error handler
$front = \Zend_Controller_Front::getInstance();
$front->unregisterPlugin("Zend_Controller_Plugin_ErrorHandler");
$response = $this->getResponse();
if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
// get errorpage
try {
// enable error handler
$front->setParam('noErrorHandler', false);
$errorPath = Config::getSystemConfig()->documents->error_pages->default;
if (Site::isSiteRequest()) {
$site = Site::getCurrentSite();
$errorPath = $site->getErrorDocument();
}
if (empty($errorPath)) {
$errorPath = "/";
}
$document = Document::getByPath($errorPath);
if (!$document instanceof Document\Page) {
// default is home
$document = Document::getById(1);
}
if ($document instanceof Document\Page) {
$params = Tool::getRoutingDefaults();
if ($module = $document->getModule()) {
$params["module"] = $module;
}
if ($controller = $document->getController()) {
$params["controller"] = $controller;
$params["action"] = "index";
}
if ($action = $document->getAction()) {
$params["action"] = $action;
}
$this->setErrorHandler($params);
$request->setParam("document", $document);
\Zend_Registry::set("pimcore_error_document", $document);
// ensure that a viewRenderer exists, and is enabled
if (!\Zend_Controller_Action_HelperBroker::hasHelper("viewRenderer")) {
$viewRenderer = new \Pimcore\Controller\Action\Helper\ViewRenderer();
\Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
}
$viewRenderer = \Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
$viewRenderer->setNoRender(false);
if ($viewRenderer->view === null) {
$viewRenderer->initView(PIMCORE_WEBSITE_PATH . "/views");
}
}
} catch (\Exception $e) {
Logger::emergency("error page not found");
}
}
// call default ZF error handler
parent::_handleError($request);
}