/**
  * @depends testGetLogs
  */
 public function testGetLog()
 {
     $log = $this->logViewer->getFirstClient()->getFirstLog();
     $this->assertInstanceOf('Syonix\\LogViewer\\LogFile', $log);
     $this->assertEquals('Log1', $log->getName());
     return $log;
 }
Esempio n. 2
0
    }
    switch ($e->getStatusCode()) {
        case 404:
            $viewer = new Syonix\LogViewer\LogViewer($app['config']['logs']);
            return $app['twig']->render('error/log_file_not_found.html.twig', array('clients' => $viewer->getClients(), 'current_client_slug' => null, 'current_log_slug' => null, 'error' => $e));
        default:
            try {
                $viewer = new Syonix\LogViewer\LogViewer($app['config']['logs']);
                $clients = $viewer->getClients();
            } catch (\Exception $e) {
                $clients = array();
            }
            return $app['twig']->render('error/error.html.twig', array('clients' => $clients, 'clientSlug' => null, 'logSlug' => null, 'message' => 'Something went wrong!', 'icon' => 'bug', 'error' => $e));
    }
});
$app->error(function (\Exception $e, $code) use($app) {
    if ($app['debug']) {
        return;
    }
    switch ($code) {
        default:
            try {
                $viewer = new Syonix\LogViewer\LogViewer($app['config']['logs']);
                $clients = $viewer->getClients();
            } catch (\Exception $e) {
                $clients = array();
            }
            return $app['twig']->render('error/error.html.twig', array('clients' => $clients, 'clientSlug' => null, 'logSlug' => null, 'message' => 'Something went wrong!', 'icon' => 'bug', 'error' => $e));
    }
});
$app->run();
Esempio n. 3
0
 $filter['logger'] = $request->query->get('logger');
 if ($filter['logger'] == "") {
     $filter['logger'] = null;
 }
 $filter['level'] = intval($request->query->get('level', 0));
 if (!($filter['level'] > 0)) {
     $filter['level'] = null;
 }
 $filter['text'] = $request->query->get('text');
 if ($filter['text'] == "") {
     $filter['text'] = null;
 }
 if ($filter['logger'] === null && $filter['level'] === null && $filter['text'] === null) {
     $filter = null;
 }
 $viewer = new Syonix\LogViewer\LogViewer($app['config']['logs']);
 $client = $viewer->getClient($clientSlug);
 if (null === $client) {
     $error = array('message' => 'The client was not found.');
     return $app->json($error, 404);
 }
 $log = $client->getLog($logSlug);
 if (null === $log) {
     $error = array('message' => 'The log file was not found.');
     return $app->json($error, 404);
 }
 $adapter = new \League\Flysystem\Adapter\Local(APP_PATH . '/cache');
 $cache = new \Syonix\LogViewer\Cache($adapter, $app['config']['cache_expire'], $app['config']['reverse_line_order']);
 $log = $cache->get($log);
 $logUrl = BASE_URL . '/api/logs/' . $client->getSlug() . '/' . $log->getSlug();
 $totalLines = $log->countLines($filter);