diff options
author | Nathan Gass | 2017-12-13 14:58:11 +0100 |
---|---|---|
committer | Nathan Gass | 2017-12-13 14:58:11 +0100 |
commit | 3d4d646cb366bd6de2bab48ce68f7c9edd2c61e9 (patch) | |
tree | 3a0492f97b9cf65a00e66547298ea2a314543ab7 | |
parent | 57d132446933d48b18da125174c3ca2396ba1dfd (diff) | |
download | itools-3d4d646cb366bd6de2bab48ce68f7c9edd2c61e9.tar.gz itools-3d4d646cb366bd6de2bab48ce68f7c9edd2c61e9.tar.bz2 itools-3d4d646cb366bd6de2bab48ce68f7c9edd2c61e9.zip |
factor out log_line from log function
-rw-r--r-- | it.class | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -75,7 +75,17 @@ static function &cloneobj(&$object) 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 = date("Y-m-d H:i:s") . "\t" . implode("\t", array_slice($args, 1)); + self::log_line($name, $line); + return $line; +} + +/** + * Append line to a logfile. Date will be added to filename + * @param $name Name of logfile. Will be in log/ of service unless it starts with / + * @param $line Line to log. + */ +static function log_line($name, $line) { $basefn = substr($name, 0, 1) == "/" ? $name : $GLOBALS['ULTRAHOME'] . "/log/$name"; $fullfn = $basefn . "-" . date('Ymd'); @@ -93,10 +103,8 @@ static function log($name /* ... */) @symlink($fullfn, $basefn); } - file_put_contents($fullfn, $line, FILE_APPEND); + file_put_contents($fullfn, $line . "\n", FILE_APPEND); } - - return $line; } |