本文整理汇总了PHP中modX::setLogTarget方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::setLogTarget方法的具体用法?PHP modX::setLogTarget怎么用?PHP modX::setLogTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::setLogTarget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resetLogging
/**
* Reset the current logging.
*
* @access public
*/
public function resetLogging() {
if ($this->_loggingRegister && $this->_prevLogTarget && $this->_prevLogLevel) {
$this->modx->setLogTarget($this->_prevLogTarget);
$this->modx->setLogLevel($this->_prevLogLevel);
$this->_loggingRegister = null;
}
}
示例2: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
require_once dirname(__FILE__) . '/build.config.php';
require_once dirname(__FILE__) . '/uthelpers.class.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->getService('error', 'error.modError', '', '');
$this->utHelpers = new UtHelpers();
$this->mc = new MyComponentProject($modx);
$this->mc->init(array(), 'unittest');
$this->mc->createCategories();
$this->mc->createBasics();
$this->modx =& $this->mc->modx;
if ($this->mc->props['categories']['UnitTest']['category'] != 'UnitTest') {
die('wrong config');
}
if (strstr($this->mc->targetRoot, 'unittest')) {
// $this->utHelpers->rrmdir($this->mc->targetRoot);
} else {
die('Wrong Target Root!');
}
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ECHO');
}
示例3: loadModxInstance
public static function loadModxInstance()
{
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
echo XPDO_CLI_MODE ? '' : '<pre>';
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ECHO');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
return $modx;
}
示例4: __construct
/**
* Constructor
*/
public function __construct(modX &$modx)
{
$this->modx = $modx;
// require original phpconsole class
$phpconsole_file = dirname(__FILE__) . '/vendor/phpconsole.php';
if (file_exists($phpconsole_file)) {
require_once $phpconsole_file;
} else {
return false;
}
// make sure phpconsole should be enabled
if (!$this->modx->getOption('phpconsole.enabled', null, false)) {
return false;
}
// load config
$this->config = new \Phpconsole\Config();
// set default project
$this->project = $this->modx->getOption('phpconsole.project', null, 'default');
$configSetting = $this->modx->fromJSON($this->modx->getOption('phpconsole.config', null, ''));
if (!empty($configSetting)) {
// load config from system setting
$this->config->loadFromArray($configSetting);
} else {
if (file_exists(MODX_CORE_PATH . 'config/phpconsole-config.inc.php')) {
// load config from file
$this->config->loadFromLocation(MODX_CORE_PATH . 'config/phpconsole-config.inc.php');
} else {
// if no config exists, switch back to the FILE logTarget
$this->modx->setLogTarget('FILE');
return false;
}
}
// initialize phpconsole
$this->phpconsole = new \Phpconsole\Phpconsole($this->config);
// set logTarget to ARRAY_EXTENDED to store all log() calls in an array
$this->modx->setLogTarget(array('target' => 'ARRAY_EXTENDED', 'options' => array('var' => &$this->logArray)));
// register a shoutdown function to log fatal errors in phpconsole
register_shutdown_function('phpconsoleFatalLogger');
}
示例5: endDebug
/**
* End the debug trail
*/
public function endDebug()
{
if ($this->modx->getOption('debug', $this->config, false)) {
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $this->debugTimeStart;
$totalTime = sprintf("%2.4f s", $totalTime);
$this->modx->log(modX::LOG_LEVEL_DEBUG, "\n<br />Execution time: {$totalTime}\n<br />");
$this->modx->setLogLevel($this->oldLogLevel);
$this->modx->setLogTarget($this->oldLogTarget);
}
}
示例6: _getConnection
/**
* Grab a persistent instance of the xPDO class to share connection data
* across multiple tests and test suites.
*
* @param array $options An array of configuration parameters.
* @return xPDO An xPDO object instance.
*/
public static function _getConnection($options = array())
{
$modx = FiTestHarness::$modx;
if (is_object($modx)) {
if (!$modx->request) {
$modx->getRequest();
}
if (!$modx->error) {
$modx->request->loadErrorHandler();
}
$modx->error->reset();
FiTestHarness::$modx = $modx;
return FiTestHarness::$modx;
}
/* include config.core.php */
$properties = array();
$config = array();
include strtr(realpath(dirname(__FILE__)) . '/config.inc.php', '\\', '/');
require_once $config['modx_base_path'] . 'config.core.php';
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
include_once strtr(realpath(dirname(__FILE__)) . '/properties.inc.php', '\\', '/');
if (!defined('MODX_REQP')) {
define('MODX_REQP', false);
}
$modx = new modX(null, $properties);
$ctx = !empty($options['ctx']) ? $options['ctx'] : 'web';
$modx->initialize($ctx);
$debug = !empty($options['debug']);
$modx->setDebug($debug);
if (!empty($properties['logTarget'])) {
$modx->setLogTarget($properties['logTarget']);
}
if (!empty($properties['logLevel'])) {
$modx->setLogLevel($properties['logLevel']);
}
$modx->user = $modx->newObject('modUser');
$modx->user->set('id', $modx->getOption('modx.test.user.id', null, 1));
$modx->user->set('username', $modx->getOption('modx.test.user.username', null, 'test'));
$modx->getRequest();
$modx->getParser();
$modx->request->loadErrorHandler();
@error_reporting(E_ALL);
@ini_set('display_errors', true);
FiTestHarness::$modx = $modx;
return $modx;
}
示例7: initDebug
/**
* Load debugging settings
*/
public function initDebug()
{
if ($this->modx->getOption('debug', $this->config, false)) {
error_reporting(E_ALL);
ini_set('display_errors', true);
$this->modx->setLogTarget('HTML');
$this->modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$debugUser = $this->config['debugUser'] == '' ? $this->modx->user->get('username') : 'anonymous';
$user = $this->modx->getObject('modUser', array('username' => $debugUser));
if ($user == null) {
$this->modx->user->set('id', $this->modx->getOption('debugUserId', $this->config, 1));
$this->modx->user->set('username', $debugUser);
} else {
$this->modx->user = $user;
}
}
}
示例8: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before each test is executed.
*/
protected function setUp()
{
// echo "\n---------------- SETUP --------------------";
require_once dirname(__FILE__) . '/build.config.php';
require_once dirname(__FILE__) . '/uthelpers.class.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$this->utHelpers = new UtHelpers();
$modx = new modX();
$modx->initialize('mgr');
$modx->getService('error', 'error.modError', '', '');
$modx->getService('lexicon', 'modLexicon');
$modx->getRequest();
$homeId = $modx->getOption('site_start');
$homeResource = $modx->getObject('modResource', $homeId);
if ($homeResource instanceof modResource) {
$modx->resource = $homeResource;
} else {
echo "\nNo Resource\n";
}
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget('ECHO');
require_once MODX_ASSETS_PATH . 'mycomponents/mycomponent/core/components/mycomponent/model/mycomponent/mycomponentproject.class.php';
/* @var $categoryObj modCategory */
$this->mc = new MyComponentProject($modx);
$this->mc->init(array(), 'unittest');
$this->modx =& $modx;
$this->category = key($this->mc->props['categories']);
$this->packageNameLower = $this->mc->packageNameLower;
if ($this->category != 'UnitTest') {
session_write_close();
die('wrong config - NEVER run unit test on a real project!');
}
$category = $this->modx->getCollection('modCategory', array('category' => 'UnitTest'));
foreach ($category as $categoryObj) {
$categoryObj->remove();
}
$namespace = $this->modx->getObject('modNamespace', array('name' => 'unittest'));
if ($namespace) {
$namespace->remove();
}
$this->utHelpers->rrmdir($this->mc->targetRoot);
$this->utHelpers->removeElements($this->modx, $this->mc);
$this->utHelpers->removeResources($this->modx, $this->mc);
//$this->mc->createCategory();
//$this->mc->createNamespace();
}
示例9: loadMODX
/**
* Loads a new modX instance
*
* @throws \RuntimeException
* @return \modX
*/
public static function loadMODX()
{
if (self::$modx) {
return self::$modx;
}
if (!file_exists(GITIFY_WORKING_DIR . 'config.core.php')) {
throw new \RuntimeException('There does not seem to be a MODX installation here. ');
}
require_once GITIFY_WORKING_DIR . 'config.core.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new \modX();
$modx->initialize('mgr');
$modx->getService('error', 'error.modError', '', '');
$modx->setLogTarget('ECHO');
self::$modx = $modx;
return $modx;
}
示例10: render
/**
* Render the controller.
*
* @return string
*/
public function render()
{
if ($this->modx->getOption('discuss.debug', null, true)) {
$this->modx->setLogTarget('ECHO');
$this->startDebugTimer();
}
foreach ($this->config as $k => $v) {
$this->setPlaceholder('controller.' . $k, $v);
}
foreach ($this->discuss->config as $k => $v) {
$this->setPlaceholder('discuss.config.' . $k, $v);
}
$this->initialize();
$allowed = $this->checkPermissions();
if ($allowed !== true) {
if (is_string($allowed)) {
$this->modx->sendRedirect($allowed);
} else {
$this->discuss->sendUnauthorizedPage();
}
}
$sessionPlace = $this->getSessionPlace();
if (!empty($sessionPlace)) {
$this->discuss->setSessionPlace($sessionPlace);
}
$this->handleActions();
$this->process();
if ($this->discuss->user->isLoggedIn) {
$this->getUserTop();
}
if ($this->getOption('showStatistics', true)) {
$this->getStatistics();
}
$title = $this->getPageTitle();
if (!empty($title)) {
$this->modx->setPlaceholder('discuss.pagetitle', $title);
}
$this->_renderBreadcrumbs();
$this->_renderModules();
$tpl = $this->getOption('pageTpl', false);
$tpl = $tpl ? $this->discuss->config['pagesPath'] . $tpl . '.tpl' : $this->config['tpl'];
$output = $this->_renderTemplate($tpl, $this->placeholders);
$output = $this->afterRender($output);
return $this->_output($output);
}
示例11: dirname
<?php
if (!defined('MODX_BASE_PATH')) {
require 'build.config.php';
}
/* define sources */
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'source_core' => $root . 'core/components/' . PKG_NAME_LOWER, 'model' => $root . 'core/components/' . PKG_NAME_LOWER . '/model/', 'schema' => $root . 'core/components/' . PKG_NAME_LOWER . '/model/schema/', 'xml' => $root . 'core/components/' . PKG_NAME_LOWER . '/model/schema/' . PKG_NAME_LOWER . '.mysql.schema.xml');
unset($root);
require MODX_CORE_PATH . 'model/modx/modx.class.php';
require $sources['build'] . '/includes/functions.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->getService('error', 'error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ECHO');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
if (!XPDO_CLI_MODE) {
echo '<pre>';
}
/** @var xPDOManager $manager */
$manager = $modx->getManager();
/** @var xPDOGenerator $generator */
$generator = $manager->getGenerator();
// Remove old model
rrmdir($sources['model'] . PKG_NAME_LOWER . '/mysql');
// Generate a new one
$generator->parseSchema($sources['xml'], $sources['model']);
$modx->log(modX::LOG_LEVEL_INFO, 'Model generated.');
if (!XPDO_CLI_MODE) {
echo '</pre>';
示例12: dirname
set_time_limit(0);
define('MODX_BASE_URL', 'http://localhost/addons/');
define('MODX_MANAGER_URL', 'http://localhost/addons/manager/');
define('MODX_ASSETS_URL', 'http://localhost/addons/assets/');
define('MODX_CONNECTORS_URL', 'http://localhost/addons/connectors/');
/* define sources */
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'source_core' => $root . 'core/components/newspublisher', 'source_assets' => $root . 'assets/components/newspublisher', 'data' => $root . '_build/data/', 'docs' => $root . 'core/components/newspublisher/docs/', 'resolvers' => $root . '_build/resolvers/');
unset($root);
/* instantiate MODx */
require_once $sources['build'] . 'build.config.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->setLogLevel(xPDO::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
/* set package info */
define('PKG_NAME', 'newspublisher');
define('PKG_VERSION', '2.1.0');
define('PKG_RELEASE', 'pl');
/* load builder */
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage(PKG_NAME, PKG_VERSION, PKG_RELEASE);
$builder->registerNamespace('newspublisher', false, true, '{core_path}components/newspublisher/');
/* create snippet objects */
/* create category */
/* @var $category modCategory */
$category = $modx->newObject('modCategory');
$category->set('id', 1);
$category->set('category', 'NewsPublisher');
示例13: dirname
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* SubscribeMe; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
require_once dirname(dirname(dirname(__FILE__))) . '/config.core.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modelPath = $modx->getOption('subscribeme.core_path', null, $modx->getOption('core_path') . 'components/subscribeme/') . 'model/';
$modx->addPackage('subscribeme', $modelPath);
$manager = $modx->getManager();
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('html');
echo <<<STYLE
<style>
pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
width: 99%;
}
</style>
STYLE;
echo 'Starting log...';
echo '<pre style="word-wrap: ">';
$manager->createObjectContainer('smSubscription');
示例14: array
/**
* Create or grab a reference to a static xPDO/modX instance.
*
* The instances can be reused by multiple tests and test suites.
*
* @param string $class A fixture class to get an instance of.
* @param string $name A unique identifier for the fixture.
* @param boolean $new
* @param array $options An array of configuration options for the fixture.
* @return object|null An instance of the specified fixture class or null on failure.
*/
public static function &getFixture($class, $name, $new = false, array $options = array())
{
if (!$new && array_key_exists($name, self::$fixtures) && self::$fixtures[$name] instanceof $class) {
$fixture =& self::$fixtures[$name];
} else {
$properties = array();
include_once dirname(dirname(dirname(__FILE__))) . '/core/model/modx/modx.class.php';
include dirname(__FILE__) . '/properties.inc.php';
self::$properties = $properties;
if (array_key_exists('debug', self::$properties)) {
self::$debug = (bool) self::$properties['debug'];
}
$fixture = null;
$driver = self::$properties['xpdo_driver'];
switch ($class) {
case 'modX':
if (!defined('MODX_REQP')) {
define('MODX_REQP', false);
}
if (!defined('MODX_CONFIG_KEY')) {
define('MODX_CONFIG_KEY', array_key_exists('config_key', self::$properties) ? self::$properties['config_key'] : 'test');
}
$fixture = new modX(null, self::$properties["{$driver}_array_options"]);
if ($fixture instanceof modX) {
$logLevel = array_key_exists('logLevel', self::$properties) ? self::$properties['logLevel'] : modX::LOG_LEVEL_WARN;
$logTarget = array_key_exists('logTarget', self::$properties) ? self::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$fixture->setLogLevel($logLevel);
$fixture->setLogTarget($logTarget);
if (!empty(self::$debug)) {
$fixture->setDebug(self::$properties['debug']);
}
$fixture->initialize(self::$properties['context']);
$fixture->user = $fixture->newObject('modUser');
$fixture->user->set('id', $fixture->getOption('modx.test.user.id', null, 1));
$fixture->user->set('username', $fixture->getOption('modx.test.user.username', null, 'test'));
$fixture->getRequest();
$fixture->getParser();
$fixture->request->loadErrorHandler();
}
break;
case 'xPDO':
$fixture = new xPDO(self::$properties["{$driver}_string_dsn_test"], self::$properties["{$driver}_string_username"], self::$properties["{$driver}_string_password"], self::$properties["{$driver}_array_options"], self::$properties["{$driver}_array_driverOptions"]);
if ($fixture instanceof xPDO) {
$logLevel = array_key_exists('logLevel', self::$properties) ? self::$properties['logLevel'] : xPDO::LOG_LEVEL_WARN;
$logTarget = array_key_exists('logTarget', self::$properties) ? self::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$fixture->setLogLevel($logLevel);
$fixture->setLogTarget($logTarget);
if (!empty(self::$debug)) {
$fixture->setDebug(self::$properties['debug']);
}
}
break;
default:
$fixture = new $class($options);
break;
}
if ($fixture !== null && $fixture instanceof $class) {
self::$fixtures[$name] = $fixture;
} else {
die("Error setting fixture {$name} of expected class {$class}.");
}
}
return $fixture;
}
示例15: array
try {
$vaporOptions = array('excludeExtraTablePrefix' => array(), 'excludeExtraTables' => array(), 'excludeFiles' => array(MODX_BASE_PATH . 'vapor', MODX_BASE_PATH . 'phpmyadmin'));
if (is_readable(VAPOR_DIR . 'config.php')) {
$vaporConfigOptions = @(include VAPOR_DIR . 'config.php');
if (is_array($vaporConfigOptions)) {
$vaporOptions = array_merge($vaporOptions, $vaporConfigOptions);
}
}
include dirname(dirname(__FILE__)) . '/config.core.php';
include MODX_CORE_PATH . 'model/modx/modx.class.php';
if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
set_time_limit(0);
}
$options = array('log_level' => xPDO::LOG_LEVEL_INFO, 'log_target' => array('target' => 'FILE', 'options' => array('filename' => 'vapor-' . strftime('%Y%m%dT%H%M%S', $startTime) . '.log')), xPDO::OPT_CACHE_DB => false, xPDO::OPT_SETUP => true);
$modx = new modX('', $options);
$modx->setLogTarget($options['log_target']);
$modx->setLogLevel($options['log_level']);
$modx->setOption(xPDO::OPT_CACHE_DB, false);
$modx->setOption(xPDO::OPT_SETUP, true);
$modx->setDebug(-1);
$modx->startTime = $startTime;
$modx->getVersionData();
$modxVersion = $modx->version['full_version'];
if (version_compare($modxVersion, '2.2.1-pl', '>=')) {
$modx->initialize('mgr', $options);
} else {
$modx->initialize('mgr');
}
if (!$modx->hasPermission('Vapor')) {
die('Access denied');
}