summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
Diffstat (limited to 'it.class')
-rw-r--r--it.class16
1 files changed, 9 insertions, 7 deletions
diff --git a/it.class b/it.class
index b097e60..6840eaa 100644
--- a/it.class
+++ b/it.class
@@ -70,14 +70,14 @@ static function &cloneobj(&$object)
/**
* Append all arguments to a logfile (tab separated). 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)
+ * @param $args... Varargs to log, will be tab separated.
*/
static function log($name /* ... */)
{
$args = func_get_args();
- $line = date("Y-m-d H:i:s") . "\t" . implode("\t", array_slice($args, 1)) . "\n";
+ $line = it::date("Y-m-d H:i:s") . "\t" . implode("\t", array_slice($args, 1)) . "\n";
$basefn = substr($name, 0, 1) == "/" ? $name : $GLOBALS['ULTRAHOME'] . "/log/$name";
- $fullfn = $basefn . "-" . date('Ymd');
+ $fullfn = $basefn . "-" . it::date('Ymd');
if (substr($fullfn, 0, 1) == "/")
{
@@ -89,7 +89,8 @@ static function log($name /* ... */)
@chmod("$fullfn.$tmp", 0664);
@rename("$fullfn.$tmp", $fullfn);
@unlink($basefn);
- @symlink($fullfn, $basefn);
+ if (@readlink($basefn) < basename($fullfn)) # may be older due to $GLOBALS['debug_time']
+ @symlink($fullfn, $basefn);
}
file_put_contents($fullfn, $line, FILE_APPEND);
@@ -262,9 +263,7 @@ static function error($p = array())
*/
static function fatal($p)
{
- $p = is_array($p) ? $p : array('title' => $p);
- $p['backtraceskip']++;
- it::error($p);
+ it::error(array('backtraceskip' => 2) + (is_array($p) ? $p : array('title' => $p)));
if ($_SERVER['REMOTE_ADDR'])
header("HTTP/1.0 500 Internal Server Error");
exit(99);
@@ -1030,6 +1029,9 @@ static function json_decode($json)
return ($data = json_decode($json)) === null && $json != 'null' ? it::error(array('title' => "invalid json", 'body' => $json)) : $data;
}
+/**
+ * Retuns sorted array. mode string can contain combinations of a for assoc, k for key, r for reverse and n for numeric
+ */
static function sort($array, $mode = "")
{
$func = it::replace(array('n' => ""), count_chars($mode, 3)) . "sort"; # count_chars sorts flags