| | |
| | | Properties = properties ?? new Dictionary<string, string>() |
| | | }; |
| | | |
| | | _logger.Log(MapLevel(severity), "{Code}: {Message}", code, message); |
| | | lock (_gate) |
| | | { |
| | | _entries.Add(entry); |
| | | AppendLog(entry); |
| | | } |
| | | |
| | | _logger.Log(MapLevel(severity), "{Code}: {Message}", code, message); |
| | | AppendLog(entry); |
| | | return entry; |
| | | } |
| | | |
| | |
| | | line += " " + string.Join(";", entry.Properties.Select(p => $"{p.Key}={p.Value}")); |
| | | } |
| | | |
| | | File.AppendAllText(_logFile, line + Environment.NewLine, Encoding.UTF8); |
| | | try |
| | | { |
| | | File.AppendAllText(_logFile, line + Environment.NewLine, Encoding.UTF8); |
| | | } |
| | | catch (IOException) |
| | | { |
| | | _logger.LogWarning("Failed to append diagnostic log file because it is currently unavailable."); |
| | | } |
| | | catch (UnauthorizedAccessException) |
| | | { |
| | | _logger.LogWarning("Failed to append diagnostic log file because access was denied."); |
| | | } |
| | | } |
| | | |
| | | private static LogLevel MapLevel(DiagnosticSeverity severity) => severity switch |