Skip to content

Commit 94713ac

Browse files
author
Marius Burkard
committed
Merge branch '4156-log-hostname' into 'develop'
Show hostname in log warning emails (#4156) Closes #4156 See merge request ispconfig/ispconfig3!1275
2 parents 38e538e + b7d4d29 commit 94713ac

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

server/lib/app.inc.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ public function __get($name) {
8888
trigger_error('Undefined property ' . $name . ' of class app', E_USER_WARNING);
8989
}
9090
}
91-
91+
9292
function setCaller($caller) {
9393
$this->_calling_script = $caller;
9494
}
95-
95+
9696
function getCaller() {
9797
return $this->_calling_script;
9898
}
99-
99+
100100
function forceErrorExit($errmsg = 'undefined') {
101101
global $conf;
102-
102+
103103
if($this->_calling_script == 'server') {
104104
@unlink($conf['temppath'] . $conf['fs_div'] . '.ispconfig_lock');
105105
}
@@ -202,9 +202,14 @@ function log($msg, $priority = 0, $dblog = true) {
202202
} // if
203203

204204
if(isset($conf['admin_notify_priority']) && $priority >= $conf['admin_notify_priority'] && $conf['admin_mail'] != '') {
205+
if($conf['hostname'] != 'localhost' && $conf['hostname'] != '') {
206+
$hostname = $conf['hostname'];
207+
} else {
208+
$hostname = exec('hostname -f');
209+
}
205210
// send notification to admin
206-
$mailBody = $log_msg;
207-
$mailSubject = substr($log_msg, 0, 50).'...';
211+
$mailBody = $hostname . " - " . $log_msg;
212+
$mailSubject = substr("[" . $hostname . "]" . " " . $log_msg, 0, 70).'...';
208213
$mailHeaders = "MIME-Version: 1.0" . "\n";
209214
$mailHeaders .= "Content-type: text/plain; charset=utf-8" . "\n";
210215
$mailHeaders .= "Content-Transfer-Encoding: 8bit" . "\n";

0 commit comments

Comments
 (0)