public override void Flush()
{
if (!IsEnabled) return;
// Flush to disk
if (writer != null)
{
writer.Flush();
}
// Only flush log files to DynamoDB when the table is active
if (!IsTableActive)
return;
// Get existing log files
var logFiles = Directory
.GetFiles(LogFileDirectory, logFileSearchPattern)
.Where(p => !IsLogFileEmpty(p));
// Use new log file for subsequent logs
lock (generalLock)
{
_currentLogFile = GetNewLogFilePath();
if (writer != null)
{
try
{
writer.Flush();
writer.Close();
}
catch { }
writer = null;
}
}
// Push log files to DynamoDB, then empty/delete them.
// Each log file is sent to DynamoDB in its own batch.
foreach (var oldLog in logFiles)
{
try
{
FlushLog(oldLog);
}
catch (Exception e)
{
DisableListener("Unable to write logs to DynamoDB: " + e);
return;
}
}
}
public override void Close()