Skip to content

Commit

Permalink
Merge pull request #4 from snakefoot/master
Browse files Browse the repository at this point in the history
NetStandard + VS2017
  • Loading branch information
QuantumNightmare authored Apr 20, 2018
2 parents 387089e + aafc7bb commit 4c4a881
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 105 deletions.
93 changes: 22 additions & 71 deletions src/NLog.Raygun/NLog.Raygun.csproj
Original file line number Diff line number Diff line change
@@ -1,77 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F5744BD5-98C2-4082-9D04-9D28536D5DBB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NLog.Raygun</RootNamespace>
<AssemblyName>NLog.Raygun</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
<TargetFrameworks>net45;netstandard2.0;netstandard1.6</TargetFrameworks>

<Version>1.0.0</Version>
<Title>NLog.Raygun</Title>
<Product>NLog.Raygun</Product>
<Company>Raygun</Company>
<Authors>Ken Burkhardt</Authors>
<Description>A custom NLog target that will push exceptions to Raygun</Description>
<Copyright>Copyright © 2015</Copyright>

<PackageTags>NLog;Raygun;Log;Logging</PackageTags>
<PackageProjectUrl>https://github.com/MindscapeHQ/NLog.Raygun</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/MindscapeHQ/NLog.Raygun/master/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/MindscapeHQ/NLog.Raygun</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mindscape.Raygun4Net, Version=5.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Mindscape.Raygun4Net.5.0.1\lib\net40\Mindscape.Raygun4Net.dll</HintPath>
</Reference>
<Reference Include="Mindscape.Raygun4Net4, Version=5.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Mindscape.Raygun4Net.5.0.1\lib\net40\Mindscape.Raygun4Net4.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=3.2.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NLog.3.2.1\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RaygunException.cs" />
<Compile Include="RayGunTarget.cs" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<PackageReference Include="NLog" Version="4.0.0" />
<PackageReference Include="Mindscape.Raygun4Net" Version="5.5.0" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<ItemGroup Condition=" '$(TargetFramework)' != 'net45' ">
<PackageReference Include="NLog" Version="4.5.0" />
<PackageReference Include="Mindscape.Raygun4Net.AspNetCore" Version="5.5.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
27 changes: 1 addition & 26 deletions src/NLog.Raygun/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,10 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NLog.Raygun")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NLog.Raygun")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("7e18fc86-3440-49e7-9c39-9e5a2e3b4e36")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: Guid("7e18fc86-3440-49e7-9c39-9e5a2e3b4e36")]
37 changes: 34 additions & 3 deletions src/NLog.Raygun/RayGunTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,21 @@ namespace NLog.Raygun
public class RayGunTarget : TargetWithLayout
{
[RequiredParameter]
public string ApiKey { get; set; }
public string ApiKey
{
get
{
SimpleLayout simpleLayout = _apiKey as SimpleLayout;
if (simpleLayout != null)
return simpleLayout.Text;
else if (_apiKey != null)
return _apiKey.ToString();
else
return null;
}
set { _apiKey = value; }
}
private Layout _apiKey;

public string Tags { get; set; }

Expand Down Expand Up @@ -110,9 +124,13 @@ protected override void Write(LogEventInfo logEvent)
exception = new RaygunException(layoutLogMessage);
}

#if NET45
string userIdentityInfo = UserIdentityInfo != null ? UserIdentityInfo.Render(logEvent) : string.Empty;
var userIdentity = string.IsNullOrEmpty(userIdentityInfo) ? null : new Mindscape.Raygun4Net.Messages.RaygunIdentifierMessage(userIdentityInfo);
_raygunClient.SendInBackground(exception, tags, userCustomData, userIdentity);
#else
_raygunClient.SendInBackground(exception, tags, userCustomData);
#endif
}

private static Exception ExtractException(LogEventInfo logEvent)
Expand Down Expand Up @@ -145,7 +163,7 @@ private static Dictionary<string, object> ExtractProperties(LogEventInfo logEven
continue;

object propertyValue = property.Value;
if (propertyValue == null || Convert.GetTypeCode(propertyValue) != TypeCode.Object || propertyValue is decimal)
if (propertyValue == null || Convert.GetTypeCode(propertyValue) != TypeCode.Object)
properties[propertyKey] = propertyValue;
else
properties[propertyKey] = propertyValue.ToString();
Expand Down Expand Up @@ -198,7 +216,20 @@ private List<string> ExtractTags(LogEventInfo logEvent, Exception exception)

private RaygunClient CreateRaygunClient()
{
var client = string.IsNullOrEmpty(ApiKey) ? new RaygunClient() : new RaygunClient(ApiKey);
RaygunClient client = null;
string apiKey = _apiKey?.Render(LogEventInfo.CreateNullEvent()) ?? string.Empty;
if (!string.IsNullOrEmpty(apiKey))
{
client = new RaygunClient(apiKey);
}
else
{
#if NET45
client = new RaygunClient();
#else
throw new ArgumentException("NLog RaygunTarget requires valid ApiKey property", nameof(ApiKey));
#endif
}

if (UseExecutingAssemblyVersion)
{
Expand Down
5 changes: 0 additions & 5 deletions src/NLog.Raygun/packages.config

This file was deleted.

0 comments on commit 4c4a881

Please sign in to comment.