本文整理汇总了PHP中Icinga\Application\Logger::info方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::info方法的具体用法?PHP Logger::info怎么用?PHP Logger::info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Application\Logger
的用法示例。
在下文中一共展示了Logger::info方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addMessage
protected function addMessage($message, $type = 'info')
{
if (!in_array($type, array('info', 'error', 'warning', 'success'))) {
throw new ProgrammingError('"%s" is not a valid notification type', $type);
}
if ($this->isCli) {
$msg = sprintf('[%s] %s', $type, $message);
switch ($type) {
case 'info':
case 'success':
Logger::info($msg);
break;
case 'warning':
Logger::warn($msg);
break;
case 'error':
Logger::error($msg);
break;
}
return;
}
$this->messages[] = (object) array('type' => $type, 'message' => $message);
}
示例2: webserverAction
/**
* Create webserver configuration
*
* USAGE:
*
* icingacli setup config webserver <apache|nginx> [options]
*
* OPTIONS:
*
* --path=<urlpath> The URL path to Icinga Web 2 [/icingaweb2]
*
* --root|--document-root=<directory> The directory from which the webserver will serve files [/path/to/icingaweb2/public]
*
* --config=<directory> Path to Icinga Web 2's configuration files [/etc/icingaweb2]
*
* --file=<filename> Write configuration to file [stdout]
*
* EXAMPLES:
*
* icingacli setup config webserver apache
*
* icingacli setup config webserver apache --path=/icingaweb2 --document-root=/usr/share/icingaweb2/public --config=/etc/icingaweb2
*
* icingacli setup config webserver apache --file=/etc/apache2/conf.d/icingaweb2.conf
*
* icingacli setup config webserver nginx
*/
public function webserverAction()
{
if (($type = $this->params->getStandalone()) === null) {
$this->fail($this->translate('Argument type is mandatory.'));
}
try {
$webserver = Webserver::createInstance($type);
} catch (ProgrammingError $e) {
$this->fail($this->translate('Unknown type') . ': ' . $type);
}
$urlPath = trim($this->params->get('path', $webserver->getUrlPath()));
if (strlen($urlPath) === 0) {
$this->fail($this->translate('The argument --path expects a URL path'));
}
$documentRoot = trim($this->params->get('root', $this->params->get('document-root', $webserver->getDocumentRoot())));
if (strlen($documentRoot) === 0) {
$this->fail($this->translate('The argument --root/--document-root expects a directory from which the webserver will serve files'));
}
$configDir = trim($this->params->get('config', $webserver->getConfigDir()));
if (strlen($configDir) === 0) {
$this->fail($this->translate('The argument --config expects a path to Icinga Web 2\'s configuration files'));
}
$webserver->setDocumentRoot($documentRoot)->setConfigDir($configDir)->setUrlPath($urlPath);
$config = $webserver->generate() . "\n";
if (($file = $this->params->get('file')) !== null) {
if (file_exists($file) === true) {
$this->fail(sprintf($this->translate('File %s already exists. Please delete it first.'), $file));
}
Logger::info($this->translate('Write %s configuration to file: %s'), $type, $file);
$re = file_put_contents($file, $config);
if ($re === false) {
$this->fail($this->translate('Could not write to file') . ': ' . $file);
}
Logger::info($this->translate('Successfully written %d bytes to file'), $re);
return true;
}
echo $config;
return true;
}
示例3: order
/**
* Order the result by the given column
*
* @param string $columnOrAlias The column or column alias to order by
* @param int $dir The sort direction or null to use default direction
*
* @return $this Fluent interface
*/
public function order($columnOrAlias, $dir = null)
{
$this->requireColumn($columnOrAlias);
$this->orderColumns[$columnOrAlias] = $columnOrAlias;
if ($this->isCustomvar($columnOrAlias)) {
$columnOrAlias = $this->getCustomvarColumnName($columnOrAlias);
} elseif ($this->hasAliasName($columnOrAlias)) {
$columnOrAlias = $this->aliasToColumnName($columnOrAlias);
} else {
Logger::info('Can\'t order by column ' . $columnOrAlias);
return $this;
}
return parent::order($columnOrAlias, $dir);
}
示例4: order
/**
* Order the result by the given alias
*
* @param string $alias The column alias to order by
* @param int $dir The sort direction or null to use the default direction
*
* @return $this
*/
public function order($alias, $dir = null)
{
$this->requireColumn($alias);
if ($this->isCustomvar($alias)) {
$column = $this->getCustomvarColumnName($alias);
} elseif ($this->hasAliasName($alias)) {
$column = $this->aliasToColumnName($alias);
$table = $this->aliasToTableName($alias);
if (isset($this->caseInsensitiveColumns[$table][$alias])) {
$column = 'LOWER(' . $column . ')';
}
} else {
Logger::info('Can\'t order by column ' . $alias);
return $this;
}
$this->orderColumns[] = $alias;
return parent::order($column, $dir);
}
示例5: order
/**
* Add a sort rule for this query
*
* If called without a specific column, the repository's defaul sort rules will be applied.
* This notifies the repository about each column being required as filter column.
*
* @param string $field The name of the column by which to sort the query's result
* @param string $direction The direction to use when sorting (asc or desc, default is asc)
* @param bool $ignoreDefault Whether to ignore any default sort rules if $field is given
*
* @return $this
*/
public function order($field = null, $direction = null, $ignoreDefault = false)
{
$sortRules = $this->getSortRules();
if ($field === null) {
// Use first available sort rule as default
if (empty($sortRules)) {
// Return early in case of no sort defaults and no given $field
return $this;
}
$sortColumns = reset($sortRules);
if (!array_key_exists('columns', $sortColumns)) {
$sortColumns['columns'] = array(key($sortRules));
}
if ($direction !== null || !array_key_exists('order', $sortColumns)) {
$sortColumns['order'] = $direction ?: static::SORT_ASC;
}
} else {
$alias = $this->repository->reassembleQueryColumnAlias($this->target, $field) ?: $field;
if (!$ignoreDefault && array_key_exists($alias, $sortRules)) {
$sortColumns = $sortRules[$alias];
if (!array_key_exists('columns', $sortColumns)) {
$sortColumns['columns'] = array($alias);
}
if ($direction !== null || !array_key_exists('order', $sortColumns)) {
$sortColumns['order'] = $direction ?: static::SORT_ASC;
}
} else {
$sortColumns = array('columns' => array($alias), 'order' => $direction);
}
}
$baseDirection = strtoupper($sortColumns['order']) === static::SORT_DESC ? static::SORT_DESC : static::SORT_ASC;
foreach ($sortColumns['columns'] as $column) {
list($column, $specificDirection) = $this->splitOrder($column);
if ($this->hasLimit() && $this->repository->providesValueConversion($this->target, $column)) {
Logger::debug('Cannot order by column "%s" in repository "%s". The query is' . ' limited and applies value conversion rules on the column', $column, $this->repository->getName());
continue;
}
try {
$this->query->order($this->repository->requireFilterColumn($this->target, $column, $this), $specificDirection ?: $baseDirection);
} catch (QueryException $_) {
Logger::info('Cannot order by column "%s" in repository "%s"', $column, $this->repository->getName());
}
}
return $this;
}
示例6: addMessage
/**
* Add a notification message
*
* @param string $message
* @param string $type
*/
protected function addMessage($message, $type = self::INFO)
{
if ($this->isCli) {
$msg = sprintf('[%s] %s', $type, $message);
switch ($type) {
case self::INFO:
case self::SUCCESS:
Logger::info($msg);
break;
case self::ERROR:
Logger::error($msg);
break;
case self::WARNING:
Logger::warning($msg);
break;
}
} else {
$this->messages[] = (object) array('type' => $type, 'message' => $message);
}
}