Skip to content

Commit aeb0a2b

Browse files
author
Till Brehm
committed
Some more changes for #4252.
1 parent 475352e commit aeb0a2b

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

server/lib/classes/cronjob.inc.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ public function getSchedule() {
7777

7878
/** run through cronjob sequence **/
7979
public function run() {
80-
81-
print "Called run() for class " . get_class($this) . "\n";
82-
print "Job has schedule: " . $this->getSchedule() . "\n";
80+
global $conf;
81+
82+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Called run() for class " . get_class($this) . "\n";
83+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Job has schedule: " . $this->getSchedule() . "\n";
8384
$this->onPrepare();
8485
$run_it = $this->onBeforeRun();
8586
if($run_it == true) {
@@ -93,9 +94,9 @@ public function run() {
9394

9495
/* this function prepares some data for the job and sets next run time if first executed */
9596
protected function onPrepare() {
96-
global $app;
97+
global $app, $conf;
9798

98-
print "Called onPrepare() for class " . get_class($this) . "\n";
99+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Called onPrepare() for class " . get_class($this) . "\n";
99100
// check the run time and values for this job
100101

101102
// get previous run data
@@ -120,15 +121,15 @@ protected function onPrepare() {
120121

121122
/* this function checks if a cron job's next runtime is reached and returns true or false */
122123
protected function onBeforeRun() {
123-
global $app;
124+
global $app, $conf;
124125

125-
print "Called onBeforeRun() for class " . get_class($this) . "\n";
126+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Called onBeforeRun() for class " . get_class($this) . "\n";
126127

127128
if($this->_running == true) return false; // job is still marked as running!
128129

129-
print "Jobs next run is " . $this->_next_run . "\n";
130+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Jobs next run is " . $this->_next_run . "\n";
130131
$reached = ISPConfigDateTime::compare($this->_next_run, ISPConfigDateTime::dbtime());
131-
print "Date compare of " . ISPConfigDateTime::to_timestamp($this->_next_run) . " and " . ISPConfigDateTime::dbtime() . " is " . $reached . "\n";
132+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Date compare of " . ISPConfigDateTime::to_timestamp($this->_next_run) . " and " . ISPConfigDateTime::dbtime() . " is " . $reached . "\n";
132133
if($reached === false) return false; // error!
133134

134135
if($reached === -1) {
@@ -152,31 +153,31 @@ protected function onBeforeRun() {
152153
$next_run = $app->cron->getNextRun(ISPConfigDateTime::dbtime());
153154
}
154155

155-
print "Jobs next run is now " . $next_run . "\n";
156+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Jobs next run is now " . $next_run . "\n";
156157

157158
$app->db->query("REPLACE INTO `sys_cron` (`name`, `last_run`, `next_run`, `running`) VALUES (?, NOW(), ?, 1)", get_class($this), ($next_run === false ? "#NULL#" : $next_run));
158159
return true;
159160
}
160161

161162
// child classes should override this!
162163
protected function onRunJob() {
163-
global $app;
164+
global $app, $conf;
164165

165-
print "Called onRun() for class " . get_class($this) . "\n";
166+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Called onRun() for class " . get_class($this) . "\n";
166167
}
167168

168169
// child classes may override this!
169170
protected function onAfterRun() {
170-
global $app;
171+
global $app, $conf;
171172

172-
print "Called onAfterRun() for class " . get_class($this) . "\n";
173+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Called onAfterRun() for class " . get_class($this) . "\n";
173174
}
174175

175176
// child classes may NOT override this!
176177
private function onCompleted() {
177-
global $app;
178+
global $app, $conf;
178179

179-
print "Called onCompleted() for class " . get_class($this) . "\n";
180+
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Called onCompleted() for class " . get_class($this) . "\n";
180181
$app->db->query("UPDATE `sys_cron` SET `running` = 0 WHERE `name` = ?", get_class($this));
181182
}
182183

0 commit comments

Comments
 (0)