You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.0 KiB
74 lines
2.0 KiB
7 years ago
|
using System;
|
||
8 years ago
|
using System.Collections.Generic;
|
||
|
using SharpRaven.Data;
|
||
|
|
||
|
namespace NzbDrone.Common.Instrumentation.Sentry
|
||
|
{
|
||
8 years ago
|
public class LidarrJsonPacketFactory : IJsonPacketFactory
|
||
8 years ago
|
{
|
||
7 years ago
|
private readonly SentryPacketCleanser _cleanser;
|
||
|
|
||
|
public LidarrJsonPacketFactory()
|
||
|
{
|
||
|
_cleanser = new SentryPacketCleanser();
|
||
|
}
|
||
|
|
||
|
private static string ShortenPath(string path)
|
||
8 years ago
|
{
|
||
|
|
||
|
if (string.IsNullOrWhiteSpace(path))
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
var index = path.IndexOf("\\src\\", StringComparison.Ordinal);
|
||
|
|
||
|
if (index <= 0)
|
||
|
{
|
||
|
return path;
|
||
|
}
|
||
|
|
||
|
return path.Substring(index + "\\src".Length);
|
||
|
}
|
||
|
|
||
|
public JsonPacket Create(string project, SentryEvent @event)
|
||
|
{
|
||
8 years ago
|
var packet = new LidarrSentryPacket(project, @event);
|
||
8 years ago
|
|
||
|
try
|
||
|
{
|
||
|
foreach (var exception in packet.Exceptions)
|
||
|
{
|
||
|
foreach (var frame in exception.Stacktrace.Frames)
|
||
|
{
|
||
|
frame.Filename = ShortenPath(frame.Filename);
|
||
|
}
|
||
|
}
|
||
7 years ago
|
|
||
|
_cleanser.CleansePacket(packet);
|
||
8 years ago
|
}
|
||
7 years ago
|
|
||
8 years ago
|
catch (Exception)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
return packet;
|
||
|
}
|
||
|
|
||
|
[Obsolete]
|
||
|
public JsonPacket Create(string project, SentryMessage message, ErrorLevel level = ErrorLevel.Info, IDictionary<string, string> tags = null,
|
||
|
string[] fingerprint = null, object extra = null)
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
|
||
|
[Obsolete]
|
||
|
public JsonPacket Create(string project, Exception exception, SentryMessage message = null, ErrorLevel level = ErrorLevel.Error,
|
||
|
IDictionary<string, string> tags = null, string[] fingerprint = null, object extra = null)
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
}
|
||
7 years ago
|
}
|