public static async Task AddLog(LogFileLine log) { try { using (var db = GetConnection()) { db.Open(); await db.ExecuteAsync(INSERT_LOG_SQL, log); db.Close(); } } catch (Exception e) { _logger.Error(e, $"Log {log.Date} {log.Time}: Error {e.Message}"); } }
private static LogFileLine ParseLog(string applicationName, string filePath, string logLine, string[] fields) { try { var log = new LogFileLine() { Application = applicationName, CanParse = true, FileName = filePath }; var values = logLine.Split(' '); for (int i = 0; i < fields.Length; i++) { var mappingAction = FieldMapping[fields[i]]; if (mappingAction == null) { log.CanParse = false; } else { try { mappingAction(log, values[i]); } catch (Exception e) { log.CanParse = false; } } } return(log); } catch (Exception e) { _logger.Error(e); return(new LogFileLine() { Application = applicationName, FileName = filePath, CanParse = false }); } }