diff options
author | 2009-06-17 18:24:09 -0400 | |
---|---|---|
committer | 2009-06-17 18:24:09 -0400 | |
commit | be11ee8c9834387dbf0d3dc7adcfafc375179294 (patch) | |
tree | 1c93df634a61cb2a01a6087fce18658f5c1a738d /frontend | |
parent | Move dbinit to shared and gave backend db access, created classes buildlog_en... (diff) | |
download | ingenue-be11ee8c9834387dbf0d3dc7adcfafc375179294.tar.gz ingenue-be11ee8c9834387dbf0d3dc7adcfafc375179294.tar.bz2 ingenue-be11ee8c9834387dbf0d3dc7adcfafc375179294.zip |
Added build logging to database, basic frontend log viewer
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/pages/logview.php | 54 | ||||
-rw-r--r-- | frontend/routing.csv | 2 |
2 files changed, 56 insertions, 0 deletions
diff --git a/frontend/pages/logview.php b/frontend/pages/logview.php new file mode 100644 index 0000000..2e9ca5a --- /dev/null +++ b/frontend/pages/logview.php @@ -0,0 +1,54 @@ +<?php +function init_logview() { + global $S; + $S['title']='Log Viewer'; +} +function body_logview() { + global $S, $request; + $q=$S['pdo']->query('SELECT DISTINCT `build` FROM `tasks`'); + while (true) { + $build=$q->fetch(PDO::FETCH_ASSOC); + if ($build === false) { + break; + } + echo '<h2>Build '.$build['build'].'</h2>'; + $r=$S['pdo']->query('SELECT * FROM `tasks` WHERE `build`="'.$build['build'].'"'.(isset($request['task']) && is_numeric($request['task'])?' AND `id`='.$request['task']:'')); + while (true) { + $task=$r->fetch(PDO::FETCH_ASSOC); + if ($task === false) { + break; + } + $task=new sql_task($task); + echo '<h3><a href="'.url('logs/task'.$task->id).'">Task '.$task->id.'</a>: '.$task->command.' '; + if (isset($task->exit)) { + if ($task->exit == 0) { + echo '<span style="color: green">[completed]</span>'; + } else { + echo '<span style="color: red">[exit status '.$task->exit.']</span>'; + } + } else { + echo '<span style="color: yellow">[running]</span>'; + } + echo '</h3>'; + if (isset($request['task']) && is_numeric($request['task'])) { + $s=$S['pdo']->query('SELECT * FROM `buildlogs` WHERE `task`='.$task->id.' ORDER BY `order` ASC'); + if ($s->rowCount()) { + echo '<code>'; + while (true) { + $entry=$s->fetch(PDO::FETCH_ASSOC); + if ($entry === false) { + break; + } + $entry=new sql_buildlog_entry($entry); + $text=str_replace("\n", "<br/>\n", htmlentities($entry->text)); + echo '<span id="entry_'.$task->id.'_'.$entry->order.'"'.($entry->stream=='stderr'?' style="color: red" ':'').'>'.$text.'</span>'; + } + echo '</code>'; + } else { + echo '<b>No output</b>'; + } + } + } + } +} +?> diff --git a/frontend/routing.csv b/frontend/routing.csv index ff7b516..f950863 100644 --- a/frontend/routing.csv +++ b/frontend/routing.csv @@ -11,6 +11,8 @@ # Home ^$ welcome +^logs$ logview +^logs/task([0-9]+)$ logview task # Session ^login$ login ^logout$ logout |