Fix expire logs
This commit is contained in:
@@ -322,7 +322,7 @@ namespace MarketData.Services
|
|||||||
UpdatePricesBigCharts(startDate); // bigcharts.marketwatch.com
|
UpdatePricesBigCharts(startDate); // bigcharts.marketwatch.com
|
||||||
UpdatePricesYahooSweep(startDate); // The sweep variation of the method is intended to be used after the BigCharts update because the sweep will take pricing_source into consideration when fetching prices.
|
UpdatePricesYahooSweep(startDate); // The sweep variation of the method is intended to be used after the BigCharts update because the sweep will take pricing_source into consideration when fetching prices.
|
||||||
resetEvents[STAGE_1].Set();
|
resetEvents[STAGE_1].Set();
|
||||||
SMSClient.SendSMSEmail("UPDATEDAILY2 UPDATEPRICESBIGCHARTS/YAHOO done.", smsUserName, smsRecipients, smsSMTPAddress, smsUserName, smsPassword);
|
SMSClient.SendSMSEmail("UPDATEDAILY2 STAGE_1 UPDATEPRICESBIGCHARTS/YAHOO done.", smsUserName, smsRecipients, smsSMTPAddress, smsUserName, smsPassword);
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_1 complete.");
|
MDTrace.WriteLine(LogLevel.DEBUG,$"STAGE_1 complete.");
|
||||||
});
|
});
|
||||||
resetEvents[STAGE_1].WaitOne(); // wait for pricing to finish
|
resetEvents[STAGE_1].WaitOne(); // wait for pricing to finish
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ namespace MarketData.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void ExpireLogs(String pathLogFiles,int expiryDays)
|
public static void ExpireLogs(String pathLogFiles,int expiryDays)
|
||||||
{
|
{
|
||||||
DateTime currentDate = DateTime.Now;
|
DateTime currentDate = DateTime.Now;
|
||||||
@@ -97,7 +96,9 @@ namespace MarketData.Utils
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
DateTime creationTime = File.GetCreationTime(logFile);
|
DateTime creationTime = File.GetCreationTime(logFile);
|
||||||
int age = Math.Abs(dateGenerator.DaysBetweenActual(currentDate, creationTime));
|
DateTime lastAccessTime = File.GetLastAccessTime(logFile);
|
||||||
|
DateTime earliestDate = lastAccessTime < creationTime? lastAccessTime : creationTime;
|
||||||
|
int age = Math.Abs(dateGenerator.DaysBetweenActual(currentDate, earliestDate));
|
||||||
Console.WriteLine($"[ExpireLogs ]{logFile} is {age} {(age>1?"days":"day")} old");
|
Console.WriteLine($"[ExpireLogs ]{logFile} is {age} {(age>1?"days":"day")} old");
|
||||||
if(age>=expiryDays)
|
if(age>=expiryDays)
|
||||||
{
|
{
|
||||||
@@ -124,14 +125,17 @@ namespace MarketData.Utils
|
|||||||
{
|
{
|
||||||
DateTime creationTime = File.GetCreationTime(logFile);
|
DateTime creationTime = File.GetCreationTime(logFile);
|
||||||
DateTime lastWriteTime = File.GetLastWriteTime(logFile);
|
DateTime lastWriteTime = File.GetLastWriteTime(logFile);
|
||||||
|
DateTime lastAccessTime = File.GetLastAccessTime(logFile);
|
||||||
|
DateTime earliestDate = lastAccessTime < creationTime? lastAccessTime : creationTime;
|
||||||
FileAttributes attributes = File.GetAttributes(logFile);
|
FileAttributes attributes = File.GetAttributes(logFile);
|
||||||
int age = Math.Abs(dateGenerator.DaysBetweenActual(currentDate, creationTime));
|
int age = Math.Abs(dateGenerator.DaysBetweenActual(currentDate, earliestDate));
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.Append($"[ShowLogs] ");
|
sb.Append($"[ShowLogs] ");
|
||||||
sb.Append($"'{logFile}'").Append(" ");
|
sb.Append($"'{logFile}'").Append(" ");
|
||||||
sb.Append($"Age:").Append(age).Append(" ");
|
sb.Append($"Age:").Append(age).Append(" ");
|
||||||
sb.Append($"Created:").Append(creationTime.ToShortDateString()).Append(" ");
|
sb.Append($"Created:").Append(creationTime.ToShortDateString()).Append(" ");
|
||||||
sb.Append($"LastWrite:").Append(lastWriteTime.ToShortDateString()).Append(" ");
|
sb.Append($"LastWrite:").Append(lastWriteTime.ToShortDateString()).Append(" ");
|
||||||
|
sb.Append($"LastAccess:").Append(lastAccessTime.ToShortDateString()).Append(" ");
|
||||||
sb.Append(FileAttributesToString(attributes));
|
sb.Append(FileAttributesToString(attributes));
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,sb.ToString());
|
MDTrace.WriteLine(LogLevel.DEBUG,sb.ToString());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user