mausch / QuartzNetWebConsole

Embeddable Quartz.Net web console
Other
160 stars 62 forks source link

MemoryLogger #21

Closed dsoltesz closed 11 years ago

dsoltesz commented 11 years ago

I would like to see the MemoryLogger make the private readonly LimitedList entries protected so that you could at least inherit from that class and then could add new methods such as AddLog, RemoveLog, ClearLog or add these public methods to the MemoryLogger itself.

mausch commented 11 years ago

Out of curiosity, what concretely would you add or remove from the log? Or what other operations would you add? Removing things from the log, in particular, doesn't sound like a good idea...

dsoltesz commented 11 years ago

For now I just took a copy of your class and created my own memory logger, adding in 2 methods

public void AddLog(string message ) { _entries.Add(new LogEntry(message)); } public void AddLog(LogEntry logEntry) { _entries.Add(logEntry); }

Now in my jobs, if I want to added in my own messages to have get displayed in the web console I can.

public abstract class JobBase : IJob { protected static readonly MemoryScheduleLogger Log = (MemoryScheduleLogger) Setup.Logger; //my custom memory logger with 2 new methods protected JobBase(){} public abstract void ExecuteJob(IJobExecutionContext context);

    public void Execute(IJobExecutionContext context)
    {
        try
        {
            ExecuteJob(context);
        }
        catch (Exception ex)
        {
            //Jobs should throw JobExecutionException if error occured.
            //Wrap internal expection iwth JobExecutionException
            var jex = new JobExecutionException(ex);
            throw jex;
        }
    }

}

[DisallowConcurrentExecution] public class EmailJob : JobBase { public override void ExecuteJob(IJobExecutionContext context) {

        //do some work ie send emails
       var message = SendEmails();
        Log.AddLog("EmailJob: " + message);

    }
}
mausch commented 11 years ago

Added Add method in 4a156fff4c9ea578ee4c10794e7c3e56d7200ad8

dsoltesz commented 11 years ago

Has nuget package been updated?

mausch commented 11 years ago

No. I don't think such a small change warrants a release. If you need this now, compile from source.