Skip to content

Commit

Permalink
Adds a mandatory info level log message for every job execution, and …
Browse files Browse the repository at this point in the history
…adds the job name to CronContext allowing jobs to use their name in log messages.

git-svn-id: http://ncron.googlecode.com/svn/trunk@64 352c818e-eda7-11de-bf31-4dec8810c1c1
  • Loading branch information
schourode committed Jan 17, 2010
1 parent 9f74d11 commit 6770849
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/NCron.Framework/CronContext.cs
Expand Up @@ -20,11 +20,13 @@ namespace NCron.Framework
{
public class CronContext
{
public string JobName { get; private set; }
public ICronJob Job { get; private set; }
public ILog Log { get; private set; }

public CronContext(ICronJob job, ILog log)
public CronContext(string jobName, ICronJob job, ILog log)
{
JobName = jobName;
Job = job;
Log = log;
}
Expand Down
4 changes: 3 additions & 1 deletion src/NCron.Service/Scheduling/SchedulingService.cs
Expand Up @@ -74,7 +74,9 @@ private void WaitCallbackHandler(object data)
using (var job = _jobFactory.GetJobByName(jobName))
using (var log = _logFactory.GetLogByName(jobName))
{
var context = new CronContext(job, log);
var context = new CronContext(jobName, job, log);

log.Info(() => string.Format("Executing job: {0}", jobName));

// This inner try-catch serves to report ICronJob failures to the ILog.
// Such exceptions are expected, and are thus handled seperately.
Expand Down

0 comments on commit 6770849

Please sign in to comment.