本文整理汇总了C#中ILog.Log方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.Log方法的具体用法?C# ILog.Log怎么用?C# ILog.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILog
的用法示例。
在下文中一共展示了ILog.Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchAsync
/// <inheritdoc/>
public override async Task<ElasticResponse> SearchAsync(
string body,
SearchRequest searchRequest,
CancellationToken token,
ILog log)
{
var stopwatch = Stopwatch.StartNew();
var response = await Task.Run(() => client.SearchAsync<string>(
Index ?? "_all",
searchRequest.DocumentType,
body,
searchParams => SetRequestParameters(searchParams, searchRequest)),
token);
stopwatch.Stop();
log.Log(TraceEventType.Verbose, null, null, "Request: POST {0}", response.RequestUrl);
log.Log(TraceEventType.Verbose, null, null, "Body:\n{0}", body);
log.Log(TraceEventType.Verbose, null, null, "Response: {0} {1} (in {2}ms)", response.HttpStatusCode, response.HttpStatusCode.HasValue ? ((HttpStatusCode)response.HttpStatusCode).ToString() : "", stopwatch.ElapsedMilliseconds);
if (!response.Success)
throw new HttpRequestException("Response status code does not indicate success: 404 (Not Found).");
return ParseResponse(response.Response, log);
}
示例2: MyProcess
static void MyProcess(ILog log)
{
log.Log(LogLevels.Diagnostic, "This is a diagnostic message");
log.Log(LogLevels.Info, "This is an information message");
log.Log(LogLevels.Warning, "This is a warning message");
log.Log(LogLevels.Error, "This is an error message: {0}", 1234);
}
示例3: Resolver
async Task IBoot.Run(CancellationToken token)
{
IResolver resolver = new Resolver(new[] {"CH.IoC."});
_log = resolver.Resolve<ILog>();
_log.Log(1, "Boot 1");
var tasks =
new[]
{
"isolated\\0",
"isolated\\1",
"isolated\\2"
}
.Select(path => Run(path, token))
.ToArray(); // force start
foreach (var task in tasks)
{
try
{
await task;
}
catch (Exception ex)
{
_log.Log(2, "Boot 2: " + ex);
}
}
while (!token.IsCancellationRequested)
{
await Task.Delay(10, token);
}
}
示例4: AngleSharpExaminer
public AngleSharpExaminer(ILog log, Uri uri, string content)
{
var parser = new HtmlParser();
_document = parser.Parse(content);
_links = new HashSet<Uri>();
foreach (var link in _document.Links)
{
var href = link.GetAttribute("href");
if (string.IsNullOrWhiteSpace(href))
{
log.Log(new LogMessage(LogType.Error, "A-tag has missing or empty href", uri));
continue;
}
href = href.Trim();
if (href[0] == '#') continue;
if (!Uri.IsWellFormedUriString(href, UriKind.RelativeOrAbsolute))
{
log.Log(new LogMessage(LogType.Error, $"A-tag has invalid href ({href})", uri));
return;
}
try
{
_links.Add(new Uri(uri, href));
}
catch (UriFormatException exception)
{
log.Log(new LogMessage(LogType.Error, $"A-tag has invalid href ({href})", exception, uri));
}
}
}
示例5: MyProcess
static void MyProcess(ILog log)
{
log.Log(LogLevels.Diagnostic, "This is a diagnostic message");
log.Log(LogLevels.Info, "This is an information message");
log.Log(LogLevels.Warning, new Dictionary<string, object>()
{
{ "param2", "override2" }
}, "This is a warning message");
log.Log(LogLevels.Error, "This is an error message: {0}", 1234);
}
示例6: DealException
public virtual void DealException(ExceptionContext filterContext, ILog log)
{
if (!filterContext.ExceptionHandled) {
this.BeforeDeal(filterContext);
HandleErrorInfo model = null;
string controllerName = (string)filterContext.RouteData.Values["controller"];
string actionName = (string)filterContext.RouteData.Values["action"];
var ex = filterContext.Exception.GetBaseException();
log.Log(ex);
model = this.GetHandleErrorInfo(ex, controllerName, actionName);
ViewResult result = new ViewResult {
ViewName = this.ViewName,
ViewData = new ViewDataDictionary<HandleErrorInfo>(model),
TempData = filterContext.Controller.TempData
};
filterContext.Result = result;
filterContext.ExceptionHandled = this.ExceptionHandled;
filterContext.HttpContext.Response.Clear();
filterContext.HttpContext.Response.StatusCode = this.StatusCode;
filterContext.HttpContext.Response.TrySkipIisCustomErrors = true;
}
}
示例7: WriteSomeLogs
private static void WriteSomeLogs(ILog logTunnel)
{
using (logTunnel.CreateScope("Starting somthing"))
{
logTunnel.Info("Test LogEntry {IntValue} {StringValue}", new
{
IntValue = 5,
StringValue = "MyValue",
Complex =
new ComplexData()
{
Complex2 =
new ComplexData()
},
});
logTunnel.Warning("My Warning");
logTunnel.Log("Custom", "Non spesific log title");
logTunnel.Error("Test LogEntry {*}", new
{
IntValue = 5,
StringValue = "MyValue",
Complex = new ComplexData()
{
//ExtraProp = 2,
Complex2 = new ComplexDataDerived(),
}
});
}
}
示例8: InternalLog
private static void InternalLog(ILog log, LogLevel logLevel, string message, Exception exception = null)
{
if (log == null)
{
return;
}
log.Log(logLevel, message, exception);
}
示例9: Server
public Server(ILog log)
{
_log = log;
_client = new AsyncSocketClient();
_client.Log += (sender, args) => {
_log.Log(args.Level, args.Message, args.Exception, args.Args);
};
ReconnectAttempts = 0;
}
示例10: DiscoveryServer
public DiscoveryServer(ILog log, string host, int port)
{
this.log = log;
subscriber = new UdpClient(port);
IPAddress addr = IPAddress.Parse(host);
subscriber.JoinMulticastGroup(addr);
subscriber.BeginReceive(ReceiveCallback, subscriber);
log.Log(LogLevel.Info, "Starting Discovery Server");
}
示例11: MainWindowViewModel
public MainWindowViewModel(ILog log)
{
_log = log;
_service = new Service();
_service.HandleRequest += HandleServiceRequest;
_serviceHost = new ServiceHost(_service);
_serviceHost.Open();
_log.Log(String.Format("The service is ready at {0}", _serviceHost.BaseAddresses.First()));
}
示例12: Log
/// <summary>
/// Log the message to the supplied event log.
/// </summary>
/// <param name="log"></param>
public void Log(ILog log)
{
// If the item is too old, then forget about
// trying to log it.
if (DateTime.Now.Subtract(_DateTime) > _OldSpan)
return;
// Log using our information
log.Log(_Level, _sMsg, _args);
}
示例13: InputServer
public InputServer(ILog log, IInputController inputController)
{
this.log = log;
this.inputController = inputController;
server = new OscServer(TransportType.Udp, IPAddress.Any, DEFAULT_VIP_PORT);
server.RegisterMethod(JOYPAD_BUTTON_EVENT);
server.RegisterMethod(MOUSE_EVENT);
server.RegisterMethod(SCROLL_EVENT);
server.RegisterMethod(KEYBOARD_EVENT);
server.RegisterMethod(VOLUME_EVENT);
server.MessageReceived += new OscMessageReceivedHandler(server_MessageReceived);
server.Start();
log.Log(LogLevel.Info, "Starting Input Server");
}
示例14: ParseResponse
internal static ElasticResponse ParseResponse(string response, ILog log)
{
var stopwatch = Stopwatch.StartNew();
using (var textReader = new JsonTextReader(new StringReader(response)))
{
var results = new JsonSerializer().Deserialize<ElasticResponse>(textReader);
stopwatch.Stop();
var resultSummary = string.Join(", ", GetResultSummary(results));
log.Log(
ElasticLinq.Logging.TraceEventType.Verbose,
null,
null,
"Deserialized {0} characters into {1} in {2}ms",
response.Length,
resultSummary,
stopwatch.ElapsedMilliseconds);
return results;
}
}
示例15: ExecuteIfExists
public void ExecuteIfExists(string fileName, string command, string arguments, ILog log)
{
if (!HasFile(fileName))
{
log.Log(string.Format("({0} not present)", fileName));
return;
}
ExecuteProcess(command, arguments, log);
}