diff --git a/Source/EasyGelf.Core/EasyGelf.Core.csproj b/Source/EasyGelf.Core/EasyGelf.Core.csproj index 19b4fbd..0351b4a 100644 --- a/Source/EasyGelf.Core/EasyGelf.Core.csproj +++ b/Source/EasyGelf.Core/EasyGelf.Core.csproj @@ -1,101 +1,36 @@ - - - + + - Debug - AnyCPU - {B928D694-5633-4F00-B70F-23F6E5F3A2DB} - Library - Properties - EasyGelf.Core - EasyGelf.Core - v4.0 - 512 - ..\ - true - + netstandard1.5;net451 + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 + + + TRACE;DEBUG;NETSTANDARD - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + + + TRACE;NETSTANDARD + - - ..\packages\RabbitMQ.Client.3.5.0\lib\net40\RabbitMQ.Client.dll - - - - + + + + 4.3.0 + - - - Properties\Version.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + 4.3.0 + + + 4.3.0 + + + 4.3.0 + - - - - - - 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}. - - - - - \ No newline at end of file + + diff --git a/Source/EasyGelf.Core/Encoders/ChunkingEncoder.cs b/Source/EasyGelf.Core/Encoders/ChunkingEncoder.cs index c65e4fa..162c6d4 100644 --- a/Source/EasyGelf.Core/Encoders/ChunkingEncoder.cs +++ b/Source/EasyGelf.Core/Encoders/ChunkingEncoder.cs @@ -4,6 +4,8 @@ namespace EasyGelf.Core.Encoders { + using System.Threading.Tasks; + public sealed class ChunkingEncoder : ITransportEncoder { private const int HeaderSize = 12; @@ -19,10 +21,10 @@ public ChunkingEncoder(IChunkedMessageIdGenerator idGenerator, int maxSize) this.maxSize = maxSize; } - public IEnumerable Encode(byte[] bytes) + public async Task> Encode(byte[] bytes) { if (bytes.Length <= maxSize) - yield return bytes; + return new[] { bytes }; else { var messageChunkSize = maxSize - HeaderSize; @@ -30,7 +32,8 @@ public IEnumerable Encode(byte[] bytes) if(chunksCount > MaxChunkCount) throw new ArgumentOutOfRangeException("bytes"); var remainingBytes = bytes.Length; - var messageId = idGenerator.GenerateId(bytes); + var messageId = await idGenerator.GenerateId(bytes); + var result = new List(); for (var chunkSequenceNumber = 0; chunkSequenceNumber < chunksCount; ++chunkSequenceNumber) { var chunkOffset = chunkSequenceNumber * messageChunkSize; @@ -43,10 +46,12 @@ public IEnumerable Encode(byte[] bytes) stream.WriteByte((byte)chunkSequenceNumber); stream.WriteByte((byte)chunksCount); stream.Write(bytes, chunkOffset, chunkBytes); - yield return stream.ToArray(); + result.Add(stream.ToArray()); } remainingBytes -= chunkBytes; } + + return result; } } } diff --git a/Source/EasyGelf.Core/Encoders/CompositeEncoder.cs b/Source/EasyGelf.Core/Encoders/CompositeEncoder.cs index f439a66..625ee02 100644 --- a/Source/EasyGelf.Core/Encoders/CompositeEncoder.cs +++ b/Source/EasyGelf.Core/Encoders/CompositeEncoder.cs @@ -3,6 +3,8 @@ namespace EasyGelf.Core.Encoders { + using System.Threading.Tasks; + public sealed class CompositeEncoder : ITransportEncoder { private readonly ITransportEncoder[] encoders; @@ -12,9 +14,12 @@ public CompositeEncoder(params ITransportEncoder[] encoders) this.encoders = encoders; } - public IEnumerable Encode(byte[] bytes) + public async Task> Encode(byte[] bytes) { - return encoders.Aggregate((IEnumerable) new List {bytes}, (current, encoder) => current.SelectMany(encoder.Encode)); + + return encoders.Aggregate( + (IEnumerable)new List { bytes }, + (current, encoder) => current.SelectMany(x => encoder.Encode(x).Result)); } } } \ No newline at end of file diff --git a/Source/EasyGelf.Core/Encoders/GZipEncoder.cs b/Source/EasyGelf.Core/Encoders/GZipEncoder.cs index 037d44f..bd9d6ec 100644 --- a/Source/EasyGelf.Core/Encoders/GZipEncoder.cs +++ b/Source/EasyGelf.Core/Encoders/GZipEncoder.cs @@ -4,17 +4,22 @@ namespace EasyGelf.Core.Encoders { + using System.Threading.Tasks; + public sealed class GZipEncoder : ITransportEncoder { - public IEnumerable Encode(byte[] bytes) + public async Task> Encode(byte[] bytes) { + var result = new List(); using (var input = new MemoryStream(bytes)) using (var output = new MemoryStream()) { using (var compressed = new GZipStream(output, CompressionMode.Compress)) CopyTo(input, compressed); - yield return output.ToArray(); + result.Add(output.ToArray()); } + + return result; } private static void CopyTo(Stream source, Stream destination) diff --git a/Source/EasyGelf.Core/Encoders/IChunkedMessageIdGenerator.cs b/Source/EasyGelf.Core/Encoders/IChunkedMessageIdGenerator.cs index cea6209..acc3255 100644 --- a/Source/EasyGelf.Core/Encoders/IChunkedMessageIdGenerator.cs +++ b/Source/EasyGelf.Core/Encoders/IChunkedMessageIdGenerator.cs @@ -1,7 +1,9 @@ namespace EasyGelf.Core.Encoders { + using System.Threading.Tasks; + public interface IChunkedMessageIdGenerator { - byte[] GenerateId(byte[] message); + Task GenerateId(byte[] message); } } \ No newline at end of file diff --git a/Source/EasyGelf.Core/Encoders/ITransportEncoder.cs b/Source/EasyGelf.Core/Encoders/ITransportEncoder.cs index cf3cade..99a0c84 100644 --- a/Source/EasyGelf.Core/Encoders/ITransportEncoder.cs +++ b/Source/EasyGelf.Core/Encoders/ITransportEncoder.cs @@ -2,8 +2,10 @@ namespace EasyGelf.Core.Encoders { + using System.Threading.Tasks; + public interface ITransportEncoder { - IEnumerable Encode(byte[] bytes); + Task> Encode(byte[] bytes); } } \ No newline at end of file diff --git a/Source/EasyGelf.Core/Encoders/MessageBasedIdGenerator.cs b/Source/EasyGelf.Core/Encoders/MessageBasedIdGenerator.cs index ca298c0..ef84268 100644 --- a/Source/EasyGelf.Core/Encoders/MessageBasedIdGenerator.cs +++ b/Source/EasyGelf.Core/Encoders/MessageBasedIdGenerator.cs @@ -7,15 +7,17 @@ namespace EasyGelf.Core.Encoders { + using System.Threading.Tasks; + //TODO Simplify message id generator public sealed class MessageBasedIdGenerator : IChunkedMessageIdGenerator { - public byte[] GenerateId(byte[] message) + public async Task GenerateId(byte[] message) { //create a bit array to store the entire message id (which is 8 bytes) var bitArray = new BitArray(64); //Read the server ip address - var ipAddresses = Dns.GetHostAddresses(Dns.GetHostName()); + var ipAddresses = await Dns.GetHostAddressesAsync(Dns.GetHostName()); var ipAddress = (from ip in ipAddresses where ip.AddressFamily == AddressFamily.InterNetwork select ip).FirstOrDefault(); @@ -49,7 +51,7 @@ public byte[] GenerateId(byte[] message) //copy all bits from bit array into a byte[] var result = new byte[8]; - bitArray.CopyTo(result, 0); + ((ICollection)bitArray).CopyTo(result, 0); return result; } diff --git a/Source/EasyGelf.Core/Properties/AssemblyInfo.cs b/Source/EasyGelf.Core/Properties/AssemblyInfo.cs index 0db6f99..0f19b9d 100644 --- a/Source/EasyGelf.Core/Properties/AssemblyInfo.cs +++ b/Source/EasyGelf.Core/Properties/AssemblyInfo.cs @@ -4,11 +4,6 @@ // 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("EasyGelf.Core")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EasyGelf.Core")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Source/EasyGelf.Core/SimpleJson.cs b/Source/EasyGelf.Core/SimpleJson.cs index d8c32f4..848e8ab 100644 --- a/Source/EasyGelf.Core/SimpleJson.cs +++ b/Source/EasyGelf.Core/SimpleJson.cs @@ -46,7 +46,7 @@ // original json parsing code from http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html -#if NETFX_CORE +#if NETFX_CORE || NETSTANDARD #define SIMPLE_JSON_TYPEINFO #endif diff --git a/Source/EasyGelf.Core/Transports/Amqp/AmqpTransport.cs b/Source/EasyGelf.Core/Transports/Amqp/AmqpTransport.cs index 7f640a6..8af6349 100644 --- a/Source/EasyGelf.Core/Transports/Amqp/AmqpTransport.cs +++ b/Source/EasyGelf.Core/Transports/Amqp/AmqpTransport.cs @@ -6,6 +6,8 @@ namespace EasyGelf.Core.Transports.Amqp { + using System.Threading.Tasks; + public sealed class AmqpTransport : ITransport { private readonly AmqpTransportConfiguration configuration; @@ -21,16 +23,16 @@ public AmqpTransport(AmqpTransportConfiguration configuration, ITransportEncoder this.messageSerializer = messageSerializer; } - public void Send(GelfMessage message) + public async Task Send(GelfMessage message) { EstablishConnection(); - foreach (var bytes in encoder.Encode(messageSerializer.Serialize(message))) + foreach (var bytes in await encoder.Encode(messageSerializer.Serialize(message))) { var basicProperties = new BasicProperties { DeliveryMode = configuration.Persistent ? (byte)2 : (byte)1 }; - channel.BasicPublish(configuration.Exchange, configuration.RoutingKey, false, false, basicProperties, bytes); + channel.BasicPublish(configuration.Exchange, configuration.RoutingKey, false, basicProperties, bytes); } } diff --git a/Source/EasyGelf.Core/Transports/BufferedTransport.cs b/Source/EasyGelf.Core/Transports/BufferedTransport.cs index 42b8ae1..00f628d 100644 --- a/Source/EasyGelf.Core/Transports/BufferedTransport.cs +++ b/Source/EasyGelf.Core/Transports/BufferedTransport.cs @@ -4,6 +4,8 @@ namespace EasyGelf.Core.Transports { + using System.Threading.Tasks; + public sealed class BufferedTransport : ITransport { private readonly BlockingCollection buffer = new BlockingCollection(); @@ -50,7 +52,7 @@ public BufferedTransport(IEasyGelfLogger logger, ITransport transport) }) {IsBackground = true, Name = "EasyGelf Buffered Transport Thread"}.Start(); } - public void Send(GelfMessage message) + public async Task Send(GelfMessage message) { buffer.Add(message, cancellationTokenSource.Token); } diff --git a/Source/EasyGelf.Core/Transports/Http/HttpTransport.cs b/Source/EasyGelf.Core/Transports/Http/HttpTransport.cs index e316e07..5274960 100644 --- a/Source/EasyGelf.Core/Transports/Http/HttpTransport.cs +++ b/Source/EasyGelf.Core/Transports/Http/HttpTransport.cs @@ -1,29 +1,30 @@ -using System.IO; -using System.Net; - + namespace EasyGelf.Core.Transports.Http { + using System; + using System.Net; + using System.Net.Http; + using System.Threading.Tasks; + public sealed class HttpTransport : ITransport { private readonly HttpTransportConfiguration configuration; private readonly IGelfMessageSerializer messageSerializer; + private HttpClient httpClient; + public HttpTransport(HttpTransportConfiguration configuration, IGelfMessageSerializer messageSerializer) { this.configuration = configuration; this.messageSerializer = messageSerializer; } - public void Send(GelfMessage message) + public async Task Send(GelfMessage message) { - var request = (HttpWebRequest)WebRequest.Create(configuration.Uri); - using (var requestStream = request.GetRequestStream()) - using (var messageStream = new MemoryStream(messageSerializer.Serialize(message))) - messageStream.CopyTo(requestStream); - request.Method = "POST"; - request.AllowAutoRedirect = false; - request.ReadWriteTimeout = request.Timeout = configuration.Timeout; - using (var response = (HttpWebResponse)request.GetResponse()) + this.PrepareHttpClient(); + + var content = new ByteArrayContent(messageSerializer.Serialize(message)); + using (var response = await this.httpClient.PostAsync(this.configuration.Uri, content)) { if (response.StatusCode == HttpStatusCode.Accepted) return; @@ -33,6 +34,18 @@ public void Send(GelfMessage message) public void Close() { + this.httpClient.SafeDispose(); + } + + private void PrepareHttpClient() + { + if (this.httpClient != null) return; + + var httpHandler = new HttpClientHandler { AllowAutoRedirect = false }; + this.httpClient = new HttpClient(httpHandler) + { + Timeout = TimeSpan.FromMilliseconds(this.configuration.Timeout) + }; } } } \ No newline at end of file diff --git a/Source/EasyGelf.Core/Transports/ITransport.cs b/Source/EasyGelf.Core/Transports/ITransport.cs index 82dcf1d..3f9b845 100644 --- a/Source/EasyGelf.Core/Transports/ITransport.cs +++ b/Source/EasyGelf.Core/Transports/ITransport.cs @@ -1,8 +1,10 @@ -namespace EasyGelf.Core.Transports +using System.Threading.Tasks; + +namespace EasyGelf.Core.Transports { public interface ITransport { - void Send(GelfMessage message); + Task Send(GelfMessage message); void Close(); } } \ No newline at end of file diff --git a/Source/EasyGelf.Core/Transports/IpTransportConfiguration.cs b/Source/EasyGelf.Core/Transports/IpTransportConfiguration.cs index 57d91fa..1c675a7 100644 --- a/Source/EasyGelf.Core/Transports/IpTransportConfiguration.cs +++ b/Source/EasyGelf.Core/Transports/IpTransportConfiguration.cs @@ -3,6 +3,8 @@ namespace EasyGelf.Core.Transports { + using System.Threading.Tasks; + public class IpTransportConfiguration { private IPEndPoint host; @@ -13,14 +15,14 @@ public class IpTransportConfiguration public int RemotePort { get; set; } - public IPEndPoint GetHost() + public async Task GetHost() { if (host != null) { return host; } - var remoteIpAddress = Dns.GetHostAddresses(RemoteAddress) + var remoteIpAddress = (await Dns.GetHostAddressesAsync(RemoteAddress)) .Shuffle() .DefaultIfEmpty(IPAddress.Loopback) .First(); diff --git a/Source/EasyGelf.Core/Transports/RetryingTransport.cs b/Source/EasyGelf.Core/Transports/RetryingTransport.cs index c3b09e5..9be0e90 100644 --- a/Source/EasyGelf.Core/Transports/RetryingTransport.cs +++ b/Source/EasyGelf.Core/Transports/RetryingTransport.cs @@ -3,6 +3,8 @@ namespace EasyGelf.Core.Transports { + using System.Threading.Tasks; + public sealed class RetryingTransport : ITransport { private readonly IEasyGelfLogger logger; @@ -18,14 +20,14 @@ public RetryingTransport(IEasyGelfLogger logger, ITransport transport, int retry this.retryDelay = retryDelay; } - public void Send(GelfMessage message) + public async Task Send(GelfMessage message) { var sendRetryCount = retryCount; while (true) { try { - transport.Send(message); + await this.transport.Send(message); break; } catch(Exception exception) diff --git a/Source/EasyGelf.Core/Transports/Tcp/ITcpConnection.cs b/Source/EasyGelf.Core/Transports/Tcp/ITcpConnection.cs index 4c8ca8f..c1b790d 100644 --- a/Source/EasyGelf.Core/Transports/Tcp/ITcpConnection.cs +++ b/Source/EasyGelf.Core/Transports/Tcp/ITcpConnection.cs @@ -3,9 +3,11 @@ namespace EasyGelf.Core.Transports.Tcp { + using System.Threading.Tasks; + public interface ITcpConnection : IDisposable { - void Open(); + Task Open(); Stream Stream { get; } } diff --git a/Source/EasyGelf.Core/Transports/Tcp/TcpConnection.cs b/Source/EasyGelf.Core/Transports/Tcp/TcpConnection.cs index b40f60f..6cb8399 100644 --- a/Source/EasyGelf.Core/Transports/Tcp/TcpConnection.cs +++ b/Source/EasyGelf.Core/Transports/Tcp/TcpConnection.cs @@ -3,6 +3,8 @@ namespace EasyGelf.Core.Transports.Tcp { + using System.Threading.Tasks; + public class TcpConnection : ITcpConnection { private readonly TcpTransportConfiguration configuration; @@ -17,25 +19,19 @@ public TcpConnection(TcpTransportConfiguration configuration) client = new TcpClient(); } - public void Open() + public async Task Open() { - client.Connect(configuration.GetHost()); + var host = await this.configuration.GetHost(); + await client.ConnectAsync(host.Address, host.Port); networkStream = client.GetStream(); } public void Dispose() { - if (networkStream != null) - { - networkStream.Close(); - } - - client.Close(); + this.networkStream?.Dispose(); + this.client.SafeDispose(); } - public Stream Stream - { - get { return networkStream; } - } + public Stream Stream => networkStream; } } diff --git a/Source/EasyGelf.Core/Transports/Tcp/TcpSslConnection.cs b/Source/EasyGelf.Core/Transports/Tcp/TcpSslConnection.cs index a4e9192..5a8eff0 100644 --- a/Source/EasyGelf.Core/Transports/Tcp/TcpSslConnection.cs +++ b/Source/EasyGelf.Core/Transports/Tcp/TcpSslConnection.cs @@ -4,6 +4,8 @@ namespace EasyGelf.Core.Transports.Tcp { + using System.Threading.Tasks; + public class TcpSslConnection : ITcpConnection { private readonly TcpTransportConfiguration configuration; @@ -18,30 +20,25 @@ public TcpSslConnection(TcpTransportConfiguration configuration) client = new TcpClient(); } - public void Open() + public async Task Open() { - client.Connect(configuration.GetHost()); + var host = await this.configuration.GetHost(); + await client.ConnectAsync(host.Address, host.Port); sslStream = new SslStream(client.GetStream()) { ReadTimeout = configuration.Timeout, WriteTimeout = configuration.Timeout }; - sslStream.AuthenticateAsClient(configuration.GetServerNameInCertificate()); + await sslStream.AuthenticateAsClientAsync(configuration.GetServerNameInCertificate()); } public void Dispose() { - if (sslStream != null) - { - sslStream.Close(); - } + this.sslStream?.Dispose(); - client.Close(); + this.client.SafeDispose(); } - public Stream Stream - { - get { return sslStream; } - } + public Stream Stream => sslStream; } } \ No newline at end of file diff --git a/Source/EasyGelf.Core/Transports/Tcp/TcpTransport.cs b/Source/EasyGelf.Core/Transports/Tcp/TcpTransport.cs index 09f7894..c5bf4ae 100644 --- a/Source/EasyGelf.Core/Transports/Tcp/TcpTransport.cs +++ b/Source/EasyGelf.Core/Transports/Tcp/TcpTransport.cs @@ -2,6 +2,8 @@ namespace EasyGelf.Core.Transports.Tcp { + using System.Threading.Tasks; + public sealed class TcpTransport : ITransport { private readonly TcpTransportConfiguration configuration; @@ -19,7 +21,7 @@ public TcpTransport(TcpTransportConfiguration configuration, } - private void EstablishConnection() + private async Task EstablishConnectionAsync() { if (connection != null) { @@ -29,7 +31,7 @@ private void EstablishConnection() try { connection = createConnection(); - connection.Open(); + await connection.Open(); } catch (Exception exception) { @@ -40,15 +42,15 @@ private void EstablishConnection() } - public void Send(GelfMessage message) + public async Task Send(GelfMessage message) { - EstablishConnection(); + await this.EstablishConnectionAsync(); var bytes = messageSerializer.Serialize(message); try { - connection.Stream.Write(bytes, 0, bytes.Length); + await connection.Stream.WriteAsync(bytes, 0, bytes.Length); connection.Stream.WriteByte(0); } catch (Exception) diff --git a/Source/EasyGelf.Core/Transports/Udp/UdpTransport.cs b/Source/EasyGelf.Core/Transports/Udp/UdpTransport.cs index 3ef3281..3e85c30 100644 --- a/Source/EasyGelf.Core/Transports/Udp/UdpTransport.cs +++ b/Source/EasyGelf.Core/Transports/Udp/UdpTransport.cs @@ -3,6 +3,8 @@ namespace EasyGelf.Core.Transports.Udp { + using System.Threading.Tasks; + public sealed class UdpTransport : ITransport { private readonly UdpTransportConfiguration configuration; @@ -16,11 +18,11 @@ public UdpTransport(UdpTransportConfiguration configuration, ITransportEncoder e this.messageSerializer = messageSerializer; } - public void Send(GelfMessage message) + public async Task Send(GelfMessage message) { using (var udpClient = new UdpClient()) - foreach (var bytes in encoder.Encode(messageSerializer.Serialize(message))) - udpClient.Send(bytes, bytes.Length, configuration.GetHost()); + foreach (var bytes in await encoder.Encode(messageSerializer.Serialize(message))) + await udpClient.SendAsync(bytes, bytes.Length, await configuration.GetHost()); } public void Close() diff --git a/Source/EasyGelf.Core/packages.config b/Source/EasyGelf.Core/packages.config deleted file mode 100644 index d79da9a..0000000 --- a/Source/EasyGelf.Core/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Source/EasyGelf.Log4Net.Example/App.config b/Source/EasyGelf.Log4Net.Example/App.config index 58262a1..713d642 100644 --- a/Source/EasyGelf.Log4Net.Example/App.config +++ b/Source/EasyGelf.Log4Net.Example/App.config @@ -1,6 +1,6 @@ - + diff --git a/Source/EasyGelf.Log4Net.Example/EasyGelf.Log4Net.Example.csproj b/Source/EasyGelf.Log4Net.Example/EasyGelf.Log4Net.Example.csproj index 4a07346..8ca2c95 100644 --- a/Source/EasyGelf.Log4Net.Example/EasyGelf.Log4Net.Example.csproj +++ b/Source/EasyGelf.Log4Net.Example/EasyGelf.Log4Net.Example.csproj @@ -1,88 +1,28 @@ - - - + + - Debug - AnyCPU - {62185BAF-1DDB-44FC-BFA0-7DBA798437E2} Exe - Properties - EasyGelf.Log4Net.Example - EasyGelf.Log4Net.Example - v4.0 - 512 - ..\ - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + netcoreapp1.1 + - - False - ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll - - - - - + + - - Properties\Version.cs - - - + + PreserveNewest + + - - Designer - - - Always - - + + 2.0.8 + + - - {b928d694-5633-4f00-b70f-23f6e5f3a2db} - EasyGelf.Core - - - {5b64942e-7197-4781-909c-e6aa5813ae9d} - EasyGelf.Log4Net - + + - - - - - 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}. - - - - \ No newline at end of file diff --git a/Source/EasyGelf.Log4Net.Example/EntryPoint.cs b/Source/EasyGelf.Log4Net.Example/EntryPoint.cs index d429dd0..8645c0a 100644 --- a/Source/EasyGelf.Log4Net.Example/EntryPoint.cs +++ b/Source/EasyGelf.Log4Net.Example/EntryPoint.cs @@ -8,7 +8,7 @@ namespace EasyGelf.Log4Net.Example { public static class EntryPoint { - private static readonly ILog Log = LogManager.GetLogger("ExampleLog"); + private static readonly ILog Log = LogManager.GetLogger("EasyGelf.Log4Net", "ExampleLog"); public static void Main() { @@ -27,7 +27,8 @@ private static void ConfigureLogging() var fileInfo = new FileInfo("log4net.config"); if (!fileInfo.Exists) throw new Exception(); - XmlConfigurator.Configure(fileInfo); + var repository = LogManager.CreateRepository("EasyGelf.Log4Net"); + XmlConfigurator.Configure(repository, fileInfo); } } } diff --git a/Source/EasyGelf.Log4Net.Example/Properties/AssemblyInfo.cs b/Source/EasyGelf.Log4Net.Example/Properties/AssemblyInfo.cs index a9067b2..032fbb5 100644 --- a/Source/EasyGelf.Log4Net.Example/Properties/AssemblyInfo.cs +++ b/Source/EasyGelf.Log4Net.Example/Properties/AssemblyInfo.cs @@ -5,11 +5,6 @@ // 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("EasyGelf.Log4Net.Example")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EasyGelf.Log4Net.Example")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Source/EasyGelf.Log4Net.Example/log4net.config b/Source/EasyGelf.Log4Net.Example/log4net.config index d3cd141..30dafa6 100644 --- a/Source/EasyGelf.Log4Net.Example/log4net.config +++ b/Source/EasyGelf.Log4Net.Example/log4net.config @@ -12,7 +12,7 @@ Easy Gelf Example Application - + @@ -20,16 +20,15 @@ Easy Gelf Example Application - + Easy Gelf Example Application - - - + + diff --git a/Source/EasyGelf.Log4Net.Example/packages.config b/Source/EasyGelf.Log4Net.Example/packages.config deleted file mode 100644 index e25c2bd..0000000 --- a/Source/EasyGelf.Log4Net.Example/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Source/EasyGelf.Log4Net/EasyGelf.Log4Net.csproj b/Source/EasyGelf.Log4Net/EasyGelf.Log4Net.csproj index b7b723b..525f387 100644 --- a/Source/EasyGelf.Log4Net/EasyGelf.Log4Net.csproj +++ b/Source/EasyGelf.Log4Net/EasyGelf.Log4Net.csproj @@ -1,99 +1,25 @@ - - - + + - Debug - AnyCPU - {5B64942E-7197-4781-909C-E6AA5813AE9D} - Library - Properties - EasyGelf.Log4Net - EasyGelf.Log4Net - v4.0 - 512 - ..\ - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 + netstandard1.5;net451 + Yuriy Pliner + + https://github.com/Pliner/EasyGelf/blob/master/license.txt + https://github.com/Pliner/EasyGelf + GELF log4net targets + GELF, log4net + Copyright Yury Pliner 2016 + https://github.com/Pliner/EasyGelf + EasyGelf.Log4Net.nuspec - - pdbonly - true - ..\..\Build\Release\EasyGelf.Log4Net\ - TRACE - prompt - 4 - - - - False - ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll - - - - - - - - Properties\Version.cs - - - - - - - - - + - - {b928d694-5633-4f00-b70f-23f6e5f3a2db} - EasyGelf.Core - + + 2.0.8 + + - - + - - - - - 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}. - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Source/EasyGelf.Log4Net/EasyGelf.Log4Net.nuspec b/Source/EasyGelf.Log4Net/EasyGelf.Log4Net.nuspec index 24e55a9..75bbd5c 100644 --- a/Source/EasyGelf.Log4Net/EasyGelf.Log4Net.nuspec +++ b/Source/EasyGelf.Log4Net/EasyGelf.Log4Net.nuspec @@ -1,5 +1,5 @@  - + EasyGelf.Log4Net $version$ @@ -15,7 +15,17 @@ Copyright Yury Pliner 2016 - - + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/EasyGelf.Log4Net/Properties/AssemblyInfo.cs b/Source/EasyGelf.Log4Net/Properties/AssemblyInfo.cs deleted file mode 100644 index b2687fb..0000000 --- a/Source/EasyGelf.Log4Net/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -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("EasyGelf.Log4Net")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EasyGelf.Log4Net")] -[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("d282076e-e95a-45c2-8f42-89444487ab98")] - diff --git a/Source/EasyGelf.Log4Net/packages.config b/Source/EasyGelf.Log4Net/packages.config deleted file mode 100644 index 40c0c7e..0000000 --- a/Source/EasyGelf.Log4Net/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Source/EasyGelf.NLog.Example/App.config b/Source/EasyGelf.NLog.Example/App.config index 58262a1..713d642 100644 --- a/Source/EasyGelf.NLog.Example/App.config +++ b/Source/EasyGelf.NLog.Example/App.config @@ -1,6 +1,6 @@ - + diff --git a/Source/EasyGelf.NLog.Example/EasyGelf.NLog.Example.csproj b/Source/EasyGelf.NLog.Example/EasyGelf.NLog.Example.csproj index 04d9df8..9e445d0 100644 --- a/Source/EasyGelf.NLog.Example/EasyGelf.NLog.Example.csproj +++ b/Source/EasyGelf.NLog.Example/EasyGelf.NLog.Example.csproj @@ -1,86 +1,26 @@ - - - + + - Debug - AnyCPU - {57F15F34-85CE-4333-B2E3-F9CC7641438C} Exe - Properties - EasyGelf.NLog.Example - EasyGelf.NLog.Example - v4.0 - 512 - ..\ - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + netcoreapp1.1 + - - False - ..\packages\NLog.3.2.0.0\lib\net40\NLog.dll - - - - + + - - Properties\Version.cs - - - + + PreserveNewest + - - - Always - Designer - - + + 1.0.0-rtm-beta5 + - - {b928d694-5633-4f00-b70f-23f6e5f3a2db} - EasyGelf.Core - - - {a761d25b-60f1-49b4-a5cd-748b57c6513c} - EasyGelf.NLog - + + - - - - - 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}. - - - - \ No newline at end of file diff --git a/Source/EasyGelf.NLog.Example/NLog.config b/Source/EasyGelf.NLog.Example/NLog.config index 8a12152..4fc3b16 100644 --- a/Source/EasyGelf.NLog.Example/NLog.config +++ b/Source/EasyGelf.NLog.Example/NLog.config @@ -6,20 +6,22 @@ - + - - + + - - + + \ No newline at end of file diff --git a/Source/EasyGelf.NLog.Example/Properties/AssemblyInfo.cs b/Source/EasyGelf.NLog.Example/Properties/AssemblyInfo.cs index 0be0623..a5442a9 100644 --- a/Source/EasyGelf.NLog.Example/Properties/AssemblyInfo.cs +++ b/Source/EasyGelf.NLog.Example/Properties/AssemblyInfo.cs @@ -5,11 +5,6 @@ // 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("EasyGelf.NLog.Example")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EasyGelf.NLog.Example")] [assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Source/EasyGelf.NLog.Example/packages.config b/Source/EasyGelf.NLog.Example/packages.config deleted file mode 100644 index 4155837..0000000 --- a/Source/EasyGelf.NLog.Example/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Source/EasyGelf.NLog/EasyGelf.NLog.csproj b/Source/EasyGelf.NLog/EasyGelf.NLog.csproj index a9e19c4..08842bd 100644 --- a/Source/EasyGelf.NLog/EasyGelf.NLog.csproj +++ b/Source/EasyGelf.NLog/EasyGelf.NLog.csproj @@ -1,94 +1,35 @@ - - - + + - Debug - AnyCPU - {A761D25B-60F1-49B4-A5CD-748B57C6513C} - Library - Properties - EasyGelf.NLog - EasyGelf.NLog - v4.0 - 512 - ..\ - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 + netstandard1.5;net451 + Yuriy Pliner + + https://github.com/Pliner/EasyGelf/blob/master/license.txt + https://github.com/Pliner/EasyGelf + GELF NLog targets + GELF, NLog + Copyright Yury Pliner 2015 + https://github.com/Pliner/EasyGelf + EasyGelf.NLog.nuspec - - pdbonly - true - ..\..\Build\Release\EasyGelf.NLog\ - TRACE - prompt - 4 - - - - False - ..\packages\NLog.3.2.0.0\lib\net40\NLog.dll - - - - - - - - Properties\Version.cs - - - - - - - + + + + 4.4.11 + + + + + 1.0.0-rtm-beta5 + + + - - {b928d694-5633-4f00-b70f-23f6e5f3a2db} - EasyGelf.Core - + + - - - Designer - + - - - - - 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}. - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Source/EasyGelf.NLog/EasyGelf.NLog.nuspec b/Source/EasyGelf.NLog/EasyGelf.NLog.nuspec index b77e085..3e0dd6a 100644 --- a/Source/EasyGelf.NLog/EasyGelf.NLog.nuspec +++ b/Source/EasyGelf.NLog/EasyGelf.NLog.nuspec @@ -1,5 +1,5 @@  - + EasyGelf.NLog $version$ @@ -15,7 +15,17 @@ Copyright Yury Pliner 2015 - - + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/EasyGelf.NLog/GelfTargetBase.cs b/Source/EasyGelf.NLog/GelfTargetBase.cs index d7ee981..4312a89 100644 --- a/Source/EasyGelf.NLog/GelfTargetBase.cs +++ b/Source/EasyGelf.NLog/GelfTargetBase.cs @@ -10,6 +10,10 @@ namespace EasyGelf.NLog { + using System.Threading.Tasks; + + using global::NLog.Common; + public abstract class GelfTargetBase : TargetWithLayout { private ITransport transport; @@ -53,8 +57,9 @@ protected GelfTargetBase() protected abstract ITransport InitializeTransport(IEasyGelfLogger logger); - protected override void Write(LogEventInfo loggingEvent) + protected override async void Write(LogEventInfo loggingEvent) { + //var loggingEvent = logEvent.LogEvent; try { var renderedEvent = Layout.Render(loggingEvent); @@ -101,7 +106,8 @@ protected override void Write(LogEventInfo loggingEvent) } } - transport.Send(messageBuilder.ToMessage()); + await transport.Send(messageBuilder.ToMessage()); + //Task.Run(() => )); } catch (Exception exception) { diff --git a/Source/EasyGelf.NLog/Properties/AssemblyInfo.cs b/Source/EasyGelf.NLog/Properties/AssemblyInfo.cs deleted file mode 100644 index 841efb0..0000000 --- a/Source/EasyGelf.NLog/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -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("EasyGelf.NLog")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EasyGelf.NLog")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[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("24522c13-4537-492d-88c4-8b03044f9f73")] diff --git a/Source/EasyGelf.NLog/packages.config b/Source/EasyGelf.NLog/packages.config deleted file mode 100644 index 802248d..0000000 --- a/Source/EasyGelf.NLog/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Source/EasyGelf.Tests/Core/Encoders/ChunkingEncoderTests.cs b/Source/EasyGelf.Tests/Core/Encoders/ChunkingEncoderTests.cs index 0493f65..12bb7e3 100644 --- a/Source/EasyGelf.Tests/Core/Encoders/ChunkingEncoderTests.cs +++ b/Source/EasyGelf.Tests/Core/Encoders/ChunkingEncoderTests.cs @@ -4,6 +4,8 @@ namespace EasyGelf.Tests.Core.Encoders { + using System.Threading.Tasks; + [TestFixture] public class ChunkingEncoderTests { @@ -17,24 +19,24 @@ public void SetUp() } [Test] - public void ShouldEncodeMessageLessThanMaxSize() + public async Task ShouldEncodeMessageLessThanMaxSize() { var bytes = new byte[32]; for (var i = 0; i < bytes.Length; ++i) bytes[i] = (byte) i; - var encodeResult = chunkingEncoder.Encode(bytes).ToArray(); + var encodeResult = (await chunkingEncoder.Encode(bytes)).ToArray(); Assert.AreEqual(1, encodeResult.Count()); Assert.AreEqual(bytes, encodeResult.ElementAt(0)); } [Test] - public void ShouldEncodeMessageGreaterThanMaxSize() + public async Task ShouldEncodeMessageGreaterThanMaxSize() { var bytes = new byte[39]; for (var i = 0; i < bytes.Length; ++i) bytes[i] = (byte)i; - var encodeResult = chunkingEncoder.Encode(bytes).ToArray(); + var encodeResult = (await chunkingEncoder.Encode(bytes)).ToArray(); Assert.AreEqual(2, encodeResult.Count()); var firstChunk = encodeResult.ElementAt(0); var secondChunk = encodeResult.ElementAt(1); diff --git a/Source/EasyGelf.Tests/Core/Encoders/CompositeEncoderTests.cs b/Source/EasyGelf.Tests/Core/Encoders/CompositeEncoderTests.cs index c9a6cba..1c92874 100644 --- a/Source/EasyGelf.Tests/Core/Encoders/CompositeEncoderTests.cs +++ b/Source/EasyGelf.Tests/Core/Encoders/CompositeEncoderTests.cs @@ -3,52 +3,39 @@ using EasyGelf.Core.Encoders; using NUnit.Framework; using System.Linq; -using Rhino.Mocks; namespace EasyGelf.Tests.Core.Encoders { + using System.Threading.Tasks; + + using Moq; + [TestFixture] public class CompositeEncoderTests { - private MockRepository mockRepository; - - [SetUp] - public void SetUp() - { - mockRepository = new MockRepository(); - } - [Test] - public void ShouldWorkWithZeroEncoders() + public async Task ShouldWorkWithZeroEncoders() { var compositeEncoder = new CompositeEncoder(); var bytes = Encoding.UTF8.GetBytes("lalala"); - var encoderResult = compositeEncoder.Encode(bytes).ToArray(); + var encoderResult = (await compositeEncoder.Encode(bytes)).ToArray(); Assert.AreEqual(1, encoderResult.Count()); Assert.AreEqual(bytes, encoderResult.ElementAt(0)); } [Test] - public void ShouldWorkWithMultipleEncoders() + public async Task ShouldWorkWithMultipleEncoders() { - var firstEncoder = mockRepository.StrictMultiMock(); - firstEncoder.Replay(); - var secondEncoder = mockRepository.StrictMultiMock(); - secondEncoder.Replay(); - var compositeEncoder = new CompositeEncoder(firstEncoder, secondEncoder); + var firstEncoder = new Mock(); + var secondEncoder = new Mock(); + var compositeEncoder = new CompositeEncoder(firstEncoder.Object, secondEncoder.Object); var bytes = Encoding.UTF8.GetBytes("lalala"); - firstEncoder.Expect(x => x.Encode(bytes)).Return(new List { bytes }); - secondEncoder.Expect(x => x.Encode(bytes)).Return(new List { bytes }); - var encoderResult = compositeEncoder.Encode(bytes).ToArray(); + firstEncoder.Setup(x => x.Encode(bytes)).Returns(Task.FromResult>(new List { bytes })); + secondEncoder.Expect(x => x.Encode(bytes)).Returns(Task.FromResult > (new List { bytes })); + var encoderResult = (await compositeEncoder.Encode(bytes)).ToArray(); Assert.AreEqual(1, encoderResult.Count()); Assert.AreEqual(bytes, encoderResult.ElementAt(0)); } - - [TearDown] - public void TearDown() - { - mockRepository.VerifyAll(); - } } } \ No newline at end of file diff --git a/Source/EasyGelf.Tests/Core/Encoders/GZipEncoderTests.cs b/Source/EasyGelf.Tests/Core/Encoders/GZipEncoderTests.cs index 88afc05..8e5eb0e 100644 --- a/Source/EasyGelf.Tests/Core/Encoders/GZipEncoderTests.cs +++ b/Source/EasyGelf.Tests/Core/Encoders/GZipEncoderTests.cs @@ -7,15 +7,17 @@ namespace EasyGelf.Tests.Core.Encoders { + using System.Threading.Tasks; + [TestFixture] public class GZipEncoderTests { [Test] - public void ShoudUnzip() + public async Task ShoudUnzip() { var encoder = new GZipEncoder(); var bytes = Encoding.UTF8.GetBytes("lalala"); - var encodeResult = encoder.Encode(bytes).ToArray(); + var encodeResult = (await encoder.Encode(bytes)).ToArray(); Assert.AreEqual(1, encodeResult.Count()); var encodedBytes = encodeResult.ElementAt(0); Assert.AreEqual(bytes, Unzip(encodedBytes)); diff --git a/Source/EasyGelf.Tests/Core/Transport/BufferedTransportTests.cs b/Source/EasyGelf.Tests/Core/Transport/BufferedTransportTests.cs index f1cec73..e27fcce 100644 --- a/Source/EasyGelf.Tests/Core/Transport/BufferedTransportTests.cs +++ b/Source/EasyGelf.Tests/Core/Transport/BufferedTransportTests.cs @@ -6,34 +6,36 @@ namespace EasyGelf.Tests.Core.Transport { + using System.Threading.Tasks; + [TestFixture] public class BufferedTransportTests { private const int MessageCount = 100; [Test] - public void ShouldSendMessage() + public async Task ShouldSendMessage() { var countingTransport = new SuceedCountingTransport(); var bufferedTransport = new BufferedTransport(new SilentLogger(), countingTransport); for (var i = 0; i < MessageCount; ++i) { var message = new GelfMessage(); - bufferedTransport.Send(message); + await bufferedTransport.Send(message); } bufferedTransport.Close(); Assert.AreEqual(MessageCount, countingTransport.Count); } [Test] - public void ShouldSkipMessageIfSendFailed() + public async Task ShouldSkipMessageIfSendFailed() { var countingTransport = new FailCountingTransport(); var bufferedTransport = new BufferedTransport(new SilentLogger(), countingTransport); for (var i = 0; i < MessageCount; ++i) { var message = new GelfMessage(); - bufferedTransport.Send(message); + await bufferedTransport.Send(message); } bufferedTransport.Close(); Assert.AreEqual(MessageCount, countingTransport.Count); @@ -47,7 +49,7 @@ public long Count { get { return Interlocked.Read(ref count); } } - public void Send(GelfMessage message) + public async Task Send(GelfMessage message) { Interlocked.Increment(ref count); } @@ -66,7 +68,7 @@ public long Count get { return Interlocked.Read(ref count); } } - public void Send(GelfMessage message) + public async Task Send(GelfMessage message) { Interlocked.Increment(ref count); throw new Exception(); diff --git a/Source/EasyGelf.Tests/Core/Transport/RetryTransportTests.cs b/Source/EasyGelf.Tests/Core/Transport/RetryTransportTests.cs index cd25c73..14ee07d 100644 --- a/Source/EasyGelf.Tests/Core/Transport/RetryTransportTests.cs +++ b/Source/EasyGelf.Tests/Core/Transport/RetryTransportTests.cs @@ -2,34 +2,34 @@ using EasyGelf.Core; using EasyGelf.Core.Transports; using NUnit.Framework; -using Rhino.Mocks; namespace EasyGelf.Tests.Core.Transport { + using System.Threading.Tasks; + + using Moq; + [TestFixture] public class RetryTransportTests { private readonly int retryCount = 5; private readonly TimeSpan retryDelay = TimeSpan.FromMilliseconds(50); - private MockRepository mockRepository; - private ITransport mainTransport; + private Mock mainTransport; private ITransport retryingTransport; [SetUp] public void SetUp() - { - mockRepository = new MockRepository(); - mainTransport = mockRepository.StrictMultiMock(); - mainTransport.Replay(); - retryingTransport = new RetryingTransport(new SilentLogger(), mainTransport, retryCount, retryDelay); + { + mainTransport = new Mock(); + retryingTransport = new RetryingTransport(new SilentLogger(), mainTransport.Object, retryCount, retryDelay); } [Test] public void ShouldContinueWhenSendSuceed() { var message = new GelfMessage(); - mainTransport.Expect(x => x.Send(message)).TentativeReturn(); + mainTransport.Setup(x => x.Send(message)); retryingTransport.Send(message); } @@ -37,25 +37,26 @@ public void ShouldContinueWhenSendSuceed() public void ShouldSendAgainIfFirstAttempFailed() { var message = new GelfMessage(); - mainTransport.Expect(x => x.Send(message)).Throw(new Exception()); - mainTransport.Expect(x => x.Send(message)).TentativeReturn(); + mainTransport.Setup(x => x.Send(message)).Throws(new Exception()); + mainTransport.Setup(x => x.Send(message)); retryingTransport.Send(message); } [Test] - [ExpectedException(typeof(Exception))] - public void ShouldFailIfAllAttemptsFailed() + public async Task ShouldFailIfAllAttemptsFailed() { - var message = new GelfMessage(); - for(var i = 0; i < retryCount; ++i) - mainTransport.Expect(x => x.Send(message)).Throw(new Exception()); - retryingTransport.Send(message); - } + try + { + var message = new GelfMessage(); + for (var i = 0; i < retryCount; ++i) mainTransport.Setup(x => x.Send(message)).Throws(new Exception()); + await retryingTransport.Send(message); + } + catch (Exception) + { + return; + } - [TearDown] - public void TearDown() - { - mockRepository.VerifyAll(); - } + throw new Exception(); + } } } \ No newline at end of file diff --git a/Source/EasyGelf.Tests/EasyGelf.Tests.csproj b/Source/EasyGelf.Tests/EasyGelf.Tests.csproj index 594a88c..a1a14f3 100644 --- a/Source/EasyGelf.Tests/EasyGelf.Tests.csproj +++ b/Source/EasyGelf.Tests/EasyGelf.Tests.csproj @@ -1,83 +1,19 @@ - - - + + - Debug - AnyCPU - {8BF8DC5F-51A6-4381-8A75-7A7D79165C5D} - Library - Properties - EasyGelf.Tests - EasyGelf.Tests - v4.0 - 512 - ..\ - true - + netstandard1.5;net451 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - - - ..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll - - - - - - - - Properties\Version.cs - - - - - - - - - - + - + + 3.7.1 + + + 4.7.25 + + - - {b928d694-5633-4f00-b70f-23f6e5f3a2db} - EasyGelf.Core - + - - - - - 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}. - - - - \ No newline at end of file diff --git a/Source/EasyGelf.Tests/Properties/AssemblyInfo.cs b/Source/EasyGelf.Tests/Properties/AssemblyInfo.cs index 967f419..c4da653 100644 --- a/Source/EasyGelf.Tests/Properties/AssemblyInfo.cs +++ b/Source/EasyGelf.Tests/Properties/AssemblyInfo.cs @@ -4,11 +4,6 @@ // 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("EasyGelf.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EasyGelf.Tests")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Source/EasyGelf.Tests/packages.config b/Source/EasyGelf.Tests/packages.config deleted file mode 100644 index 87e360f..0000000 --- a/Source/EasyGelf.Tests/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Source/EasyGelf.sln b/Source/EasyGelf.sln index 14e6c0b..6d45e3c 100644 --- a/Source/EasyGelf.sln +++ b/Source/EasyGelf.sln @@ -1,6 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.13 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyGelf.Log4Net", "EasyGelf.Log4Net\EasyGelf.Log4Net.csproj", "{5B64942E-7197-4781-909C-E6AA5813AE9D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyGelf.Core", "EasyGelf.Core\EasyGelf.Core.csproj", "{B928D694-5633-4F00-B70F-23F6E5F3A2DB}"