Last active
January 16, 2018 22:56
-
-
Save droyad/6d0cf8b88d3d55df6ae83a325290aa9d to your computer and use it in GitHub Desktop.
LibLog logger
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
void Main() | |
{ | |
Halibut.Logging.LogProvider.SetCurrentLogProvider(new ConsoleLogProvider()); | |
var rt = new HalibutRuntime(new X509Certificate2()); | |
rt.Poll(new Uri("http://example.com"), new ServiceEndPoint("http://example.com", "")); | |
Thread.Sleep(10000); | |
} | |
class ConsoleLogProvider : Halibut.Logging.ILogProvider | |
{ | |
public Logger GetLogger(string name) => new ConsoleLogger(name).Log; | |
public IDisposable OpenMappedContext(string key, string value) => null; | |
public IDisposable OpenNestedContext(string message) => null; | |
public class ConsoleLogger | |
{ | |
string _name; | |
public ConsoleLogger(string name) | |
{ | |
_name = name; | |
} | |
public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception = null, params object[] formatParameters) | |
{ | |
Console.WriteLine($"From: {_name}, Message: {string.Format(messageFunc(), formatParameters)}"); | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment