diff options
| -rw-r--r-- | it.class | 17 | 
1 files changed, 9 insertions, 8 deletions
| @@ -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);  		}  	}	  } |