using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Common.ScheduledTasks.Tasks
{
///
/// Class ReloadLoggerFileTask
///
public class ReloadLoggerFileTask : BaseScheduledTask
{
///
/// Initializes a new instance of the class.
///
/// The kernel.
/// The task manager.
/// The logger.
public ReloadLoggerFileTask(IKernel kernel, ITaskManager taskManager, ILogger logger)
: base(kernel, taskManager, logger)
{
}
///
/// Gets the default triggers.
///
/// IEnumerable{BaseTaskTrigger}.
protected override IEnumerable GetDefaultTriggers()
{
var trigger = new DailyTrigger { TimeOfDay = TimeSpan.FromHours(0) }; //12am
return new[] { trigger };
}
///
/// Executes the internal.
///
/// The cancellation token.
/// The progress.
/// Task.
protected override Task ExecuteInternal(CancellationToken cancellationToken, IProgress progress)
{
cancellationToken.ThrowIfCancellationRequested();
progress.Report(0);
return Task.Run(() => Kernel.ReloadLogger());
}
///
/// Gets the name.
///
/// The name.
public override string Name
{
get { return "Start new log file"; }
}
///
/// Gets the description.
///
/// The description.
public override string Description
{
get { return "Moves logging to a new file to help reduce log file sizes."; }
}
}
}