Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
Added Feature to adjust the TraceLevel based on Environment Variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
bofirial committed Jun 12, 2017
1 parent b9f9388 commit 1ade009
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions Melody49Notifier/Melody49Notifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ namespace Melody49Notifier
{
public static class Melody49Notifier
{

[FunctionName("Melody49Notifier")]
public static void Run([TimerTrigger("0 0 8-18 * * FRI")]TimerInfo myTimer, TraceWriter log)
public static void Run([TimerTrigger("0/10 * * * * * ")]TimerInfo myTimer, TraceWriter log) //[TimerTrigger("0 0 8-18 * * FRI")]TimerInfo myTimer, TraceWriter log)
{
SetTraceLevel(log);

log.Info($"C# Timer trigger function started at: {DateTime.Now}.");

ICurrentTheaterScheduleDataFileManager currentTheaterScheduleDataFileManager = new CurrentTheaterScheduleDataFileManager(log);
Expand All @@ -32,7 +33,27 @@ public static void Run([TimerTrigger("0 0 8-18 * * FRI")]TimerInfo myTimer, Trac
log.Info($"C# Timer trigger function completed at: {DateTime.Now}.");
}

private static bool TheaterScheduleHasUpdated(TraceWriter log, ICurrentTheaterScheduleDataFileManager currentTheaterScheduleDataFileManager, out TheaterSchedule currentTheaterSchedule)
private static void SetTraceLevel(TraceWriter log)
{
switch (Environment.GetEnvironmentVariable("TraceLevel")?.ToLower())
{
case "error":
log.Level = System.Diagnostics.TraceLevel.Error;
break;
case "warning":
log.Level = System.Diagnostics.TraceLevel.Warning;
break;
case "verbose":
log.Level = System.Diagnostics.TraceLevel.Verbose;
break;
case "info":
default:
log.Level = System.Diagnostics.TraceLevel.Info;
break;
}
}

private static bool TheaterScheduleHasUpdated(TraceWriter log, ICurrentTheaterScheduleDataFileManager currentTheaterScheduleDataFileManager, out TheaterSchedule currentTheaterSchedule)
{
ICurrentTheaterScheduleWebRequestManager currentTheaterScheduleWebRequestManager = new CurrentTheaterScheduleWebRequestManager(log, new TheaterScheduleHTMLParser(log));
ITheaterScheduleComparer theaterScheduleComparer = new TheaterScheduleComparer(log);
Expand Down

0 comments on commit 1ade009

Please sign in to comment.