本文整理汇总了PHP中Terminus::getLogger方法的典型用法代码示例。如果您正苦于以下问题:PHP Terminus::getLogger方法的具体用法?PHP Terminus::getLogger怎么用?PHP Terminus::getLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus
的用法示例。
在下文中一共展示了Terminus::getLogger方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Instantiates object, sets cache and session
*
* @return [TerminusCommand] $this
*/
public function __construct()
{
//Load commonly used data from cache
$this->cache = Terminus::getCache();
$this->logger = Terminus::getLogger();
$this->outputter = Terminus::getOutputter();
$this->session = Session::instance();
if (!Terminus::isTest()) {
$this->checkForUpdate();
}
}
示例2: testSetLogger
public function testSetLogger()
{
// This test assumes that the debug output defaults to off.
$file_name = getLogFileName();
$message = 'The sky is the daily bread of the eyes.';
setOutputDestination($file_name);
Terminus::getLogger()->debug($message);
$output = retrieveOutput($file_name);
$this->assertFalse(strpos($output, $message) !== false);
Terminus::setLogger(['debug' => true, 'format' => 'json']);
Terminus::getLogger()->debug($message);
$output = retrieveOutput($file_name);
$this->assertTrue(strpos($output, $message) !== false);
resetOutputDestination($file_name);
}
示例3: invalidPositionals
/**
* Returns invalid positionals, if any. False if not.
*
* @param array $args The arguments to evaluate for invalid positionals
* @return string|bool Returns the first invalid positional or false
*/
public function invalidPositionals($args)
{
$positionals = $this->querySpec(array('type' => 'positional'));
$args_count = count($args);
for ($i = 0; $i < $args_count; $i++) {
if (!isset($positionals[$i]['token'])) {
continue;
}
$token = preg_replace('#\\[?\\<([a-zA-Z].*)\\>\\]?.*#s', '$1', $positionals[$i]['token']);
if (in_array(trim($token), array('commands', 'email'))) {
// We exit here because the wp and drush commands need to not have
// validation running since their commands are dependent on their
// respective code bases.
return false;
}
$regex = "#^({$token})\$#s";
\Terminus::getLogger()->debug("Positional match {$regex}");
if (!preg_match($regex, $args[$i])) {
return $args[$i];
}
}
return false;
}
示例4: writeAliases
/**
* Retrieves and writes Pantheon aliases to a file
*
* @param string $location Name of the file to which to write aliases
* @return bool
*/
private function writeAliases($location)
{
$logger = Terminus::getLogger();
if (is_dir($location)) {
$message = 'Please provide a full path with filename,';
$message .= ' e.g. {location}/pantheon.aliases.drushrc.php';
$logger->error($message, compact('location'));
}
$file_exists = file_exists($location);
// Create the directory if it doesn't yet exist
$dirname = dirname($location);
if (!is_dir($dirname)) {
mkdir($dirname, 0700, true);
}
$content = $this->getAliases();
$handle = fopen($location, 'w+');
fwrite($handle, $content);
fclose($handle);
chmod($location, 0700);
$message = 'Pantheon aliases created';
if ($file_exists) {
$message = 'Pantheon aliases updated';
}
$logger->info($message);
}
示例5: simpleRequest
/**
* Simplified request method for Pantheon API
*
* @param [string] $path API path (URL)
* @param [array] $options Options for the request
* [string] method GET is default
* [mixed] data Native PHP data structure (e.g. int, string array, or
* simple object) to be sent along with the request. Will be encoded as
* JSON for you.
* @return [array] $data
*/
public static function simpleRequest($path, $options = array())
{
$method = 'get';
if (isset($options['method'])) {
$method = $options['method'];
unset($options['method']);
}
$url = sprintf('%s://%s:%s/api/%s', TERMINUS_PROTOCOL, TERMINUS_HOST, TERMINUS_PORT, $path);
if (Session::getValue('session')) {
$options['cookies'] = array('X-Pantheon-Session' => Session::getValue('session'));
}
try {
Terminus::getLogger()->debug('URL: {url}', compact('url'));
$resp = Request::send($url, $method, $options);
} catch (Guzzle\Http\Exception\BadResponseException $e) {
throw new TerminusException('API Request Error: {msg}', array('msg' => $e->getMessage()));
}
$json = $resp->getBody(true);
$data = array('info' => $resp->getInfo(), 'headers' => $resp->getRawHeaders(), 'json' => $json, 'data' => json_decode($json), 'status_code' => $resp->getStatusCode());
return $data;
}