summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2010-06-29 13:22:21 +0000
committerUrban Müller2010-06-29 13:22:21 +0000
commitfc5a7cf003163399236d97cf6e1d6d564823984c (patch)
treec03d6fdb001cb3e7fb93e34e9aa19a9badcf03dd
parentfe4d9d7d1242264365c3cd310510521dc6af5e3a (diff)
downloaditools-fc5a7cf003163399236d97cf6e1d6d564823984c.tar.gz
itools-fc5a7cf003163399236d97cf6e1d6d564823984c.tar.bz2
itools-fc5a7cf003163399236d97cf6e1d6d564823984c.zip
allow absolut paths in it::log
-rw-r--r--it.class17
1 files changed, 9 insertions, 8 deletions
diff --git a/it.class b/it.class
index b1ed522..b02892d 100644
--- a/it.class
+++ b/it.class
@@ -71,28 +71,29 @@ static function &cloneobj(&$object)
/**
- * Append a line to a logfile in log/. Date will be added to filename and line
- * @param $name Name of logfile
+ * Append a line to a logfile. Date will be added to filename and line
+ * @param $name Name of logfile. Will be in log/ of service unless it starts with /
* @param $line1 Line to append (varargs)
*/
static function log($name /* ... */)
{
$args = func_get_args();
$line = date("Y-m-d H:i:s") . "\t" . implode("\t", array_slice($args, 1)) . "\n";
- $fn = $GLOBALS['ULTRAHOME'] . "/log/$name-" . date('Ymd');
+ $basefn = substr($name, 0, 1) == "/" ? $name : $GLOBALS['ULTRAHOME'] . "/log/$name";
+ $fullfn = $basefn . "-" . date('Ymd');
- $existed = file_exists($fn);
+ $existed = file_exists($fullfn);
- if (isset($GLOBALS['ULTRAHOME']) && ($fh = fopen($fn, "a")))
+ if (substr($fullfn, 0, 1) == "/" && ($fh = fopen($fullfn, "a")))
{
fputs($fh, $line);
fclose($fh);
if (!$existed)
{
- @chgrp($fn, "www");
- @unlink($GLOBALS['ULTRAHOME'] . "/log/$name");
- @symlink($fn, $GLOBALS['ULTRAHOME'] . "/log/$name");
+ @chgrp($fullfn, "www");
+ @unlink($basefn);
+ @symlink($fullfn, $basefn);
}
}
}