From 7ec6608d170d61bee84768b3d7aa0186c21e7dd8 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 18 Nov 2015 15:43:45 +0100 Subject: it::sort docs --- it.class | 3 +++ 1 file changed, 3 insertions(+) (limited to 'it.class') diff --git a/it.class b/it.class index b097e60..d44d502 100644 --- a/it.class +++ b/it.class @@ -1030,6 +1030,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 -- cgit v1.2.3 From 2a9fe38e75a5a991981c5e6f4aa2e6f43c392b36 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 30 Nov 2015 14:02:24 +0100 Subject: adapt to new stackdump offsets --- it.class | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index d44d502..8159dd5 100644 --- a/it.class +++ b/it.class @@ -262,9 +262,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); -- cgit v1.2.3 From 81cf679bdb76ca49364bae20ff9a90f52a8cf07a Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 7 Jan 2016 17:11:18 +0100 Subject: allow setting of exact timestamp to late add old entries --- it.class | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 8159dd5..39a1372 100644 --- a/it.class +++ b/it.class @@ -70,14 +70,18 @@ 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. datetime => ... can be in first arg (dangerous) */ static function log($name /* ... */) { $args = func_get_args(); - $line = date("Y-m-d H:i:s") . "\t" . implode("\t", array_slice($args, 1)) . "\n"; + $name = array_shift($args); + if (is_array($args[0])) + $p = array_shift($args); + $timestamp = $p['datetime'] ? strtotime($p['datetime']) : time(); + $line = date("Y-m-d H:i:s", $timestamp) . "\t" . implode("\t", $args) . "\n"; $basefn = substr($name, 0, 1) == "/" ? $name : $GLOBALS['ULTRAHOME'] . "/log/$name"; - $fullfn = $basefn . "-" . date('Ymd'); + $fullfn = $basefn . "-" . date('Ymd', $timestamp); if (substr($fullfn, 0, 1) == "/") { -- cgit v1.2.3 From 14675eb397487df6ffa55e399fa585fee7f41da1 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 7 Jan 2016 17:35:57 +0100 Subject: more compact code, correctly maintain link --- it.class | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 39a1372..3c9c46c 100644 --- a/it.class +++ b/it.class @@ -76,9 +76,7 @@ static function log($name /* ... */) { $args = func_get_args(); $name = array_shift($args); - if (is_array($args[0])) - $p = array_shift($args); - $timestamp = $p['datetime'] ? strtotime($p['datetime']) : time(); + $timestamp = is_array($args[0]) && ($p = array_shift($args)) && $p['datetime'] ? strtotime($p['datetime']) : time(); $line = date("Y-m-d H:i:s", $timestamp) . "\t" . implode("\t", $args) . "\n"; $basefn = substr($name, 0, 1) == "/" ? $name : $GLOBALS['ULTRAHOME'] . "/log/$name"; $fullfn = $basefn . "-" . date('Ymd', $timestamp); @@ -93,7 +91,8 @@ static function log($name /* ... */) @chmod("$fullfn.$tmp", 0664); @rename("$fullfn.$tmp", $fullfn); @unlink($basefn); - @symlink($fullfn, $basefn); + if (@readlink($basefn) < basename($fullfn)) + @symlink($fullfn, $basefn); } file_put_contents($fullfn, $line, FILE_APPEND); -- cgit v1.2.3 From 7c4ad5b54006acc27b6dc22d3d746d15a2d14520 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 7 Jan 2016 17:56:14 +0100 Subject: rely on $GLOBALS["debug_time"] --- it.class | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 3c9c46c..6840eaa 100644 --- a/it.class +++ b/it.class @@ -70,16 +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 $args... Varargs to log, will be tab separated. datetime => ... can be in first arg (dangerous) + * @param $args... Varargs to log, will be tab separated. */ static function log($name /* ... */) { $args = func_get_args(); - $name = array_shift($args); - $timestamp = is_array($args[0]) && ($p = array_shift($args)) && $p['datetime'] ? strtotime($p['datetime']) : time(); - $line = date("Y-m-d H:i:s", $timestamp) . "\t" . implode("\t", $args) . "\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', $timestamp); + $fullfn = $basefn . "-" . it::date('Ymd'); if (substr($fullfn, 0, 1) == "/") { @@ -91,7 +89,7 @@ static function log($name /* ... */) @chmod("$fullfn.$tmp", 0664); @rename("$fullfn.$tmp", $fullfn); @unlink($basefn); - if (@readlink($basefn) < basename($fullfn)) + if (@readlink($basefn) < basename($fullfn)) # may be older due to $GLOBALS['debug_time'] @symlink($fullfn, $basefn); } -- cgit v1.2.3