Commit e24861b9 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1104 Use SetDevid() & SetPid() without crappy strings around them.

You can't do anything with the DeviceID or the PID within the log class
because they're wrapped with crap. The wrap stuff is now done when
building the log string.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 58149d60
...@@ -152,8 +152,8 @@ class ZLog { ...@@ -152,8 +152,8 @@ class ZLog {
self::$logger->SetUser($user); self::$logger->SetUser($user);
self::$logger->SetAuthUser(Request::GetAuthUser()); self::$logger->SetAuthUser(Request::GetAuthUser());
self::$logger->SetSpecialLogUsers($specialLogUsers); self::$logger->SetSpecialLogUsers($specialLogUsers);
self::$logger->SetDevid('['. Request::GetDeviceID() .']'); self::$logger->SetDevid(Request::GetDeviceID());
self::$logger->SetPidstr('[' . str_pad(@getmypid(),5," ",STR_PAD_LEFT) . ']'); self::$logger->SetPid(@getmypid());
self::$logger->AfterInitialize(); self::$logger->AfterInitialize();
} }
return self::$logger; return self::$logger;
......
...@@ -71,9 +71,10 @@ class FileLog extends Log { ...@@ -71,9 +71,10 @@ class FileLog extends Log {
* @return string * @return string
*/ */
public function BuildLogString($loglevel, $message) { public function BuildLogString($loglevel, $message) {
$log = Utils::GetFormattedTime() . ' ' . $this->GetPidstr() . ' ' . $this->GetLogLevelString($loglevel, $loglevel >= LOGLEVEL_INFO) . ' ' . $this->GetUser();
$log = Utils::GetFormattedTime() .' ['. str_pad($this->GetPid(),5," ",STR_PAD_LEFT) .'] '. $this->GetLogLevelString($loglevel, $loglevel >= LOGLEVEL_INFO) . ' ' . $this->GetUser();
if (LOGLEVEL >= LOGLEVEL_DEVICEID || (LOGUSERLEVEL >= LOGLEVEL_DEVICEID && $this->IsAuthUserInSpecialLogUsers())) { if (LOGLEVEL >= LOGLEVEL_DEVICEID || (LOGUSERLEVEL >= LOGLEVEL_DEVICEID && $this->IsAuthUserInSpecialLogUsers())) {
$log .= ' ' . $this->GetDevid(); $log .= ' ['. $this->GetDevid() .']';
} }
$log .= ' ' . $message; $log .= ' ' . $message;
return $log; return $log;
......
...@@ -43,7 +43,7 @@ abstract class Log { ...@@ -43,7 +43,7 @@ abstract class Log {
/** /**
* @var string * @var string
*/ */
protected $pidstr = ''; protected $pid = '';
/** /**
* @var array * @var array
...@@ -165,8 +165,8 @@ abstract class Log { ...@@ -165,8 +165,8 @@ abstract class Log {
* @access public * @access public
* @return string * @return string
*/ */
public function GetPidstr() { public function GetPid() {
return $this->pidstr; return $this->pid;
} }
/** /**
...@@ -177,8 +177,8 @@ abstract class Log { ...@@ -177,8 +177,8 @@ abstract class Log {
* @access public * @access public
* @return void * @return void
*/ */
public function SetPidstr($value) { public function SetPid($value) {
$this->pidstr = $value; $this->pid = $value;
} }
/** /**
......
...@@ -167,7 +167,7 @@ class Syslog extends Log { ...@@ -167,7 +167,7 @@ class Syslog extends Log {
$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) {
$log .= $this->GetDevid(); $log .= '['. $this->GetDevid() .']';
} }
$log .= ' ' . $message; $log .= ' ' . $message;
return $log; return $log;
......
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