diff options
-rw-r--r-- | it.class | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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) == "/") { |