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 {
self::$logger->SetUser($user);
self::$logger->SetAuthUser(Request::GetAuthUser());
self::$logger->SetSpecialLogUsers($specialLogUsers);
self::$logger->SetDevid('['. Request::GetDeviceID() .']');
self::$logger->SetPidstr('[' . str_pad(@getmypid(),5," ",STR_PAD_LEFT) . ']');
self::$logger->SetDevid(Request::GetDeviceID());
self::$logger->SetPid(@getmypid());
self::$logger->AfterInitialize();
}
return self::$logger;
......
......@@ -71,9 +71,10 @@ class FileLog extends Log {
* @return string
*/
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())) {
$log .= ' ' . $this->GetDevid();
$log .= ' ['. $this->GetDevid() .']';
}
$log .= ' ' . $message;
return $log;
......
......@@ -43,7 +43,7 @@ abstract class Log {
/**
* @var string
*/
protected $pidstr = '';
protected $pid = '';
/**
* @var array
......@@ -165,8 +165,8 @@ abstract class Log {
* @access public
* @return string
*/
public function GetPidstr() {
return $this->pidstr;
public function GetPid() {
return $this->pid;
}
/**
......@@ -177,8 +177,8 @@ abstract class Log {
* @access public
* @return void
*/
public function SetPidstr($value) {
$this->pidstr = $value;
public function SetPid($value) {
$this->pid = $value;
}
/**
......
......@@ -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->GetUser();
if ($loglevel >= LOGLEVEL_DEVICEID) {
$log .= $this->GetDevid();
$log .= '['. $this->GetDevid() .']';
}
$log .= ' ' . $message;
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