Commit 45724e4a authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1104 Make parameter optional of BuildLogString().

Released under the Affero GNU General Public License (AGPL) version 3.
parent 070537c6
...@@ -75,12 +75,12 @@ class FileLog extends Log { ...@@ -75,12 +75,12 @@ class FileLog extends Log {
* *
* @param int $loglevel * @param int $loglevel
* @param string $message * @param string $message
* @param boolean $includeUserDevice puts username and device in the string * @param boolean $includeUserDevice puts username and device in the string, default: true
* *
* @access public * @access public
* @return string * @return string
*/ */
public function BuildLogString($loglevel, $message, $includeUserDevice) { public function BuildLogString($loglevel, $message, $includeUserDevice = true) {
$log = Utils::GetFormattedTime() .' ['. str_pad($this->GetPid(),5," ",STR_PAD_LEFT) .'] '. $this->GetLogLevelString($loglevel, $loglevel >= LOGLEVEL_INFO); $log = Utils::GetFormattedTime() .' ['. str_pad($this->GetPid(),5," ",STR_PAD_LEFT) .'] '. $this->GetLogLevelString($loglevel, $loglevel >= LOGLEVEL_INFO);
if ($includeUserDevice) { if ($includeUserDevice) {
...@@ -107,7 +107,7 @@ class FileLog extends Log { ...@@ -107,7 +107,7 @@ class FileLog extends Log {
* @return void * @return void
*/ */
protected function Write($loglevel, $message) { protected function Write($loglevel, $message) {
$data = $this->BuildLogString($loglevel, $message, true) . PHP_EOL; $data = $this->BuildLogString($loglevel, $message) . PHP_EOL;
@file_put_contents(LOGFILE, $data, FILE_APPEND); @file_put_contents(LOGFILE, $data, FILE_APPEND);
} }
...@@ -133,7 +133,7 @@ class FileLog extends Log { ...@@ -133,7 +133,7 @@ class FileLog extends Log {
*/ */
protected function afterLog($loglevel, $message) { protected function afterLog($loglevel, $message) {
if ($loglevel & (LOGLEVEL_FATAL | LOGLEVEL_ERROR | LOGLEVEL_WARN)) { if ($loglevel & (LOGLEVEL_FATAL | LOGLEVEL_ERROR | LOGLEVEL_WARN)) {
$data = $this->BuildLogString($loglevel, $message, true) . PHP_EOL; $data = $this->BuildLogString($loglevel, $message) . PHP_EOL;
@file_put_contents(LOGERRORFILE, $data, FILE_APPEND); @file_put_contents(LOGERRORFILE, $data, FILE_APPEND);
} }
} }
......
...@@ -157,13 +157,14 @@ class Syslog extends Log { ...@@ -157,13 +157,14 @@ class Syslog extends Log {
/** /**
* Build the log string for syslog. * Build the log string for syslog.
* *
* @param int $loglevel * @param int $loglevel
* @param string $message * @param string $message
* @param boolean $includeUserDevice puts username and device in the string, default: true
* *
* @access public * @access public
* @return string * @return string
*/ */
public function BuildLogString($loglevel, $message) { public function BuildLogString($loglevel, $message, $includeUserDevice = true) {
$log = $this->GetLogLevelString($loglevel); // Never pad syslog log because syslog log are usually read with a software. $log = $this->GetLogLevelString($loglevel); // Never pad syslog log because syslog log are usually read with a software.
$log .= $this->GetUser(); $log .= $this->GetUser();
if ($loglevel >= LOGLEVEL_DEVICEID) { if ($loglevel >= LOGLEVEL_DEVICEID) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment