aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2011-02-02 01:21:04 +0100
committerLaurent Bachelier <laurent@bachelier.name>2011-02-02 01:21:04 +0100
commitda9112d13f064de617f406cfcddd7e299f6dcd1c (patch)
tree60c3c21463619bdab22538d23e839c394c63746f
parentMerge branch 'fork' (diff)
downloadsymfttpd-da9112d13f064de617f406cfcddd7e299f6dcd1c.tar.xz
Colorize the full log line, more/better colors
-rw-r--r--lib/Tail.php8
-rwxr-xr-xspawn15
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/Tail.php b/lib/Tail.php
index 00f21ae..a5bf2ee 100644
--- a/lib/Tail.php
+++ b/lib/Tail.php
@@ -66,6 +66,8 @@ class Tail
class MultiTail
{
protected $tails = array();
+ protected $prefixes = array();
+ protected $postfixes = array();
/**
* Adds a Tail to watch
@@ -74,9 +76,11 @@ class MultiTail
*
* @author Laurent Bachelier <laurent@bachelier.name>
*/
- public function add($name, $tail)
+ public function add($name, $tail, $prefix = '', $postfix = '')
{
$this->tails[$name] = $tail;
+ $this->prefixes[$name] = $prefix;
+ $this->postfixes[$name] = $postfix;
}
/**
@@ -104,7 +108,7 @@ class MultiTail
{
if (is_string($line))
{
- echo $name.': '.$line;
+ echo $this->prefixes[$name].$name.': '.$line.$this->postfixes[$name];
return true;
}
diff --git a/spawn b/spawn
index 9bfd24e..507b933 100755
--- a/spawn
+++ b/spawn
@@ -84,8 +84,12 @@ Template::writeConfig($options);
// Pretty information. Nothing interesting code-wise.
log_message('lighttpd started on '
+ . Color::style('bright')
. (strlen($options['bind']) ? $options['bind'] : 'all interfaces')
- . ', port '.$options['port'].'.');
+ . Color::style('normal')
+ . ', port '
+ . Color::style('bright') . $options['port'] . Color::style('normal')
+ . '.');
log_message("\nAvailable applications:");
$apps = array();
foreach (new DirectoryIterator($project_path.'/web') as $file)
@@ -101,7 +105,8 @@ $host = in_array($options['bind'], array(false, '0.0.0.0', '::'), true)
sort($apps);
foreach ($apps as $app)
{
- log_message(' http://'.$host.':'.$options['port'].'/'.$app);
+ log_message(' http://'.$host.':'.$options['port']
+ .'/'.Color::style('bright').$app.Color::style('normal'));
}
log_message("\nPress Ctrl+C to stop serving.");
flush();
@@ -116,8 +121,10 @@ else
if ($options['tail'])
{
$multitail = new MultiTail();
- $multitail->add(Color::fgColor('blue').'lighttpd-access'.Color::style('normal'), new Tail($options['log_dir'].'/access.log'));
- $multitail->add(Color::fgColor('red').'lighttpd-error'.Color::style('normal'), new Tail($options['log_dir'].'/error.log'));
+ $multitail->add('access', new Tail($options['log_dir'].'/access.log'),
+ Color::fgColor('blue'), Color::style('normal'));
+ $multitail->add(' error', new Tail($options['log_dir'].'/error.log'),
+ Color::style('bright').Color::fgColor('red'), Color::style('normal'));
// We have to do it before the fork to capture the startup messages
$multitail->consume();
}