This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
2,596 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Source/CakeMail.RestClient.IntegrationTests/ConsoleLogProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace CakeMail.RestClient.IntegrationTests | ||
{ | ||
using Logging; | ||
using System; | ||
using System.Globalization; | ||
|
||
// Inspired by: https://github.com/damianh/LibLog/blob/master/src/LibLog.Example.ColoredConsoleLogProvider/ColoredConsoleLogProvider.cs | ||
public class ConsoleLogProvider : ILogProvider | ||
{ | ||
|
||
public Logger GetLogger(string name) | ||
{ | ||
return (logLevel, messageFunc, exception, formatParameters) => | ||
{ | ||
if (messageFunc == null) | ||
{ | ||
return true; // All log levels are enabled | ||
} | ||
|
||
var message = string.Format(CultureInfo.InvariantCulture, messageFunc(), formatParameters); | ||
if (exception != null) | ||
{ | ||
message = message + "|" + exception; | ||
} | ||
Console.WriteLine("{0} | {1} | {2} | {3}", DateTime.UtcNow, logLevel, name, message); | ||
|
||
return true; | ||
}; | ||
} | ||
|
||
public IDisposable OpenNestedContext(string message) | ||
{ | ||
return NullDisposable.Instance; | ||
} | ||
|
||
public IDisposable OpenMappedContext(string key, string value) | ||
{ | ||
return NullDisposable.Instance; | ||
} | ||
|
||
private class NullDisposable : IDisposable | ||
{ | ||
internal static readonly IDisposable Instance = new NullDisposable(); | ||
|
||
public void Dispose() | ||
{ } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.