Exemple #1
0
 public function setUp()
 {
     $this->logger = new Logger('test');
     $this->logger->pushHandler(new StreamHandler('php://output'));
     $this->configSkeleton = [Manager::CFG_TITLE => 'Dummy configuration for test use', Manager::CFG_VERSION => '1.0', Manager::CFG_CONST => [], Manager::CFG_SERVICE => [], Manager::CFG_COMPONENTS => [], Manager::CFG_ACTIONS => []];
 }
Exemple #2
0
    $options['v'] = null;
}
if (!isset($options['verbose'])) {
    $options['verbose'] = null;
}
if ($options['v'] === 'vv' || strcasecmp($options['verbose'], 'debug') === 0) {
    $log_level = Logger::DEBUG;
} elseif ($options['v'] === 'v' || strcasecmp($options['verbose'], 'info') === 0) {
    $log_level = Logger::INFO;
} elseif ($options['v'] === false || $options['verbose'] === false) {
    $log_level = Logger::NOTICE;
} else {
    $log_level = Logger::WARNING;
}
$logger = new Logger('main');
$logger->pushHandler(new StreamHandler(sprintf('%s/log/%s.log', __DIR__, date('Ymd-His')), min($log_level, Logger::INFO)));
$logger->pushHandler(new StreamHandler('php://output', $log_level));
try {
    if (!isset($argv[++$opt_num])) {
        throw new \InvalidArgumentException(sprintf("Usage: %s [-v[v|vv]|--verbose [debug|info]] CONFIG.json", $argv[0]));
    }
    $config_file = $argv[$opt_num];
    if (!is_readable($config_file)) {
        throw new \RuntimeException("Config file is not readable.");
    }
    $config = json_decode(file_get_contents($config_file), true);
    if (!is_array($config)) {
        throw new \InvalidArgumentException('Config file is not valid JSON: ' . json_last_error_msg());
    }
    exit(Manager::run($config, $logger));
} catch (\Exception $e) {