本文整理汇总了PHP中Monolog\Logger::setHandlers方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::setHandlers方法的具体用法?PHP Logger::setHandlers怎么用?PHP Logger::setHandlers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Logger
的用法示例。
在下文中一共展示了Logger::setHandlers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Register this plates view provider with a Pimple container
*
* @param string $name
* @param array $settings
*/
public function __construct($name = 'slim-app', $settings = [])
{
$this->name = $name;
$this->monolog = new Logger($this->name);
$this->settings = array_merge($this->settings, $settings);
if (null !== $this->settings['timezone']) {
if (is_string($this->settings['timezone'])) {
$this->settings['timezone'] = new \DateTimeZone($this->settings['timezone']);
}
Logger::setTimezone($this->settings['timezone']);
}
$this->monolog->setHandlers($this->settings['handlers']);
$levels = array_keys(Logger::getLevels());
if (!in_array(strtoupper($this->settings['level']), $levels)) {
$this->settings['level'] = 'debug';
}
if ($path = $this->settings['directory']) {
if ($path === 'syslog') {
$this->useSyslog($this->name, $this->settings['level']);
} elseif (is_dir($path)) {
$path .= '/' . $this->name;
$this->useRotatingFiles($path, $this->settings['level']);
}
}
}
示例2: setupHandlers
/**
* @param $handlers
* @param $logOnlyThisHandler
* @return bool
*/
protected function setupHandlers($handlers, $logOnlyThisHandler)
{
if ($logOnlyThisHandler) {
$this->logger->setHandlers($handlers);
return true;
}
foreach ($handlers as $handler) {
$this->logger->pushHandler($handler);
}
}
示例3: setUp
public function setUp()
{
$this->logger = new Logger(__CLASS__);
$this->testHandler = new TestHandler();
$streamHandler = new StreamHandler('/tmp/test.log', LogLevel::INFO);
$this->logger->setHandlers([$streamHandler, $this->testHandler]);
/** @var SoapSettings $settings */
$this->settings = FactoryMuffin::instance('WebservicesNl\\Protocol\\Soap\\Client\\SoapSettings');
$this->manager = new Manager();
$this->manager->createEndpoint('https://ws1.webservices.nl/soap_doclit');
}
示例4: testSetHandlers
/**
* @covers Monolog\Logger::setHandlers
*/
public function testSetHandlers()
{
$logger = new Logger(__METHOD__);
$handler1 = new TestHandler();
$handler2 = new TestHandler();
$logger->pushHandler($handler1);
$logger->setHandlers(array($handler2));
// handler1 has been removed
$this->assertEquals(array($handler2), $logger->getHandlers());
$logger->setHandlers(array("AMapKey" => $handler1, "Woop" => $handler2));
// Keys have been scrubbed
$this->assertEquals(array($handler1, $handler2), $logger->getHandlers());
}
示例5: setHandlers
/**
* Set handlers, replacing all existing ones.
*
* If a map is passed, keys will be ignored.
*
* @param \Monolog\HandlerInterface[] $handlers
* @return $this
* @static
*/
public static function setHandlers($handlers)
{
return \Monolog\Logger::setHandlers($handlers);
}
示例6: exit
}
$config = Yaml::parse(file_get_contents($arguments["data"] . "/config.yml"));
if (empty($config)) {
print "Could not parse config file";
exit(2);
}
//@FIXME move to application, refactor with symfony config mapping
try {
Validator\ConfigValidator::validate($config);
} catch (InvalidConfigurationException $e) {
throw new Exception\UserException($e->getMessage());
}
$action = isset($config['action']) ? $config['action'] : $action;
$config = $config['parameters'];
if ($action !== 'run') {
$logger->setHandlers(array(new NullHandler(Logger::INFO)));
}
// move encrypted params to non-ecrypted
if (isset($config['elastic']['#host'])) {
$config['elastic']['host'] = $config['elastic']['#host'];
unset($config['elastic']['#host']);
}
if (isset($config['elastic']['ssh']['keys']['#private'])) {
$config['elastic']['ssh']['keys']['private'] = $config['elastic']['ssh']['keys']['#private'];
unset($config['elastic']['ssh']['keys']['#private']);
}
// data path
$config['path'] = $arguments["data"] . '/in/tables';
$app = new Application($config, $logger);
$result = $app->run($action, $config);
if ($action !== 'run') {