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