summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass2017-12-13 14:58:11 +0100
committerNathan Gass2017-12-13 14:58:11 +0100
commit3d4d646cb366bd6de2bab48ce68f7c9edd2c61e9 (patch)
tree3a0492f97b9cf65a00e66547298ea2a314543ab7
parent57d132446933d48b18da125174c3ca2396ba1dfd (diff)
downloaditools-3d4d646cb366bd6de2bab48ce68f7c9edd2c61e9.tar.gz
itools-3d4d646cb366bd6de2bab48ce68f7c9edd2c61e9.tar.bz2
itools-3d4d646cb366bd6de2bab48ce68f7c9edd2c61e9.zip
factor out log_line from log function
-rw-r--r--it.class16
1 files changed, 12 insertions, 4 deletions
diff --git a/it.class b/it.class
index e54137e..0ca1460 100644
--- a/it.class
+++ b/it.class
@@ -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;
}