using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Tasks;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Common.ScheduledTasks.Tasks
{
///
/// Class ReloadLoggerFileTask
///
[Export(typeof(IScheduledTask))]
public class ReloadLoggerFileTask : BaseScheduledTask
{
///
/// 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(new TaskProgress { PercentComplete = 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."; }
}
}
}