/** * 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']); } } }
/** * @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); } }
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'); }
/** * @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()); }
/** * 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); }
} $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') {