diff options
author | Urban Müller | 2016-01-07 17:11:18 +0100 |
---|---|---|
committer | Urban Müller | 2016-01-07 17:11:18 +0100 |
commit | 81cf679bdb76ca49364bae20ff9a90f52a8cf07a (patch) | |
tree | f08ebb96de700f037a53981ab147437356034dba | |
parent | 17131f9ef8dfb33271a031978d66a2cde1d6f18e (diff) | |
download | itools-81cf679bdb76ca49364bae20ff9a90f52a8cf07a.tar.gz itools-81cf679bdb76ca49364bae20ff9a90f52a8cf07a.tar.bz2 itools-81cf679bdb76ca49364bae20ff9a90f52a8cf07a.zip |
allow setting of exact timestamp to late add old entries
-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) == "/") { |