mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
CE-936 Add option to log the running of quartz jobs
This commit is contained in:
@ -30,6 +30,7 @@ import com.kingsrook.qqq.backend.core.logging.QLogger;
|
|||||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
import com.kingsrook.qqq.backend.core.scheduler.schedulable.SchedulableType;
|
import com.kingsrook.qqq.backend.core.scheduler.schedulable.SchedulableType;
|
||||||
import com.kingsrook.qqq.backend.core.scheduler.schedulable.runner.SchedulableRunner;
|
import com.kingsrook.qqq.backend.core.scheduler.schedulable.runner.SchedulableRunner;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
@ -43,6 +44,7 @@ public class QuartzJobRunner implements Job
|
|||||||
{
|
{
|
||||||
private static final QLogger LOG = QLogger.getLogger(QuartzJobRunner.class);
|
private static final QLogger LOG = QLogger.getLogger(QuartzJobRunner.class);
|
||||||
|
|
||||||
|
private static Level logLevel = null;
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -62,6 +64,10 @@ public class QuartzJobRunner implements Job
|
|||||||
Map<String, Object> params = (Map<String, Object>) context.getJobDetail().getJobDataMap().get("params");
|
Map<String, Object> params = (Map<String, Object>) context.getJobDetail().getJobDataMap().get("params");
|
||||||
|
|
||||||
SchedulableRunner schedulableRunner = QCodeLoader.getAdHoc(SchedulableRunner.class, schedulableType.getRunner());
|
SchedulableRunner schedulableRunner = QCodeLoader.getAdHoc(SchedulableRunner.class, schedulableType.getRunner());
|
||||||
|
if(logLevel != null)
|
||||||
|
{
|
||||||
|
LOG.log(logLevel, "Running QuartzJob", null, logPair("type", schedulableType.getName()), logPair("name", context.getJobDetail().getKey().getName()), logPair("params", params));
|
||||||
|
}
|
||||||
schedulableRunner.run(params);
|
schedulableRunner.run(params);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
@ -74,4 +80,13 @@ public class QuartzJobRunner implements Job
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public static void setLogLevel(Level level)
|
||||||
|
{
|
||||||
|
logLevel = level;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user