mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-23 02:05:27 +02:00
Cleanse exceptions in event logs
This commit is contained in:
parent
df672487cf
commit
404e6d68ea
@ -60,33 +60,36 @@ protected override void Write(LogEventInfo logEvent)
|
||||
{
|
||||
try
|
||||
{
|
||||
var log = new Log();
|
||||
log.Time = logEvent.TimeStamp;
|
||||
log.Message = CleanseLogMessage.Cleanse(logEvent.FormattedMessage);
|
||||
|
||||
log.Logger = logEvent.LoggerName;
|
||||
var log = new Log
|
||||
{
|
||||
Time = logEvent.TimeStamp,
|
||||
Logger = logEvent.LoggerName,
|
||||
Level = logEvent.Level.Name
|
||||
};
|
||||
|
||||
if (log.Logger.StartsWith("NzbDrone."))
|
||||
{
|
||||
log.Logger = log.Logger.Remove(0, 9);
|
||||
}
|
||||
|
||||
var message = logEvent.FormattedMessage;
|
||||
|
||||
if (logEvent.Exception != null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(log.Message))
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
{
|
||||
log.Message = logEvent.Exception.Message;
|
||||
message = logEvent.Exception.Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.Message += ": " + logEvent.Exception.Message;
|
||||
message += ": " + logEvent.Exception.Message;
|
||||
}
|
||||
|
||||
log.Exception = logEvent.Exception.ToString();
|
||||
log.Exception = CleanseLogMessage.Cleanse(logEvent.Exception.ToString());
|
||||
log.ExceptionType = logEvent.Exception.GetType().ToString();
|
||||
}
|
||||
|
||||
log.Level = logEvent.Level.Name;
|
||||
log.Message = CleanseLogMessage.Cleanse(message);
|
||||
|
||||
var connectionInfo = _connectionStringFactory.LogDbConnection;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user