Skip to content

Instantly share code, notes, and snippets.

View sommmen's full-sized avatar

sommmen

View GitHub Profile
@davidfowl
davidfowl / TimeHttpEvents.cs
Last active April 6, 2024 20:17
Using Yarp.Telemetry.Consumption to track outbound network events (this package isn't tied to YARP)
using System.Diagnostics;
using System.Net.Sockets;
using System.Security.Authentication;
using Yarp.Telemetry.Consumption;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTelemetryConsumer<TelemetryConsumer>();
var app = builder.Build();
@litetex
litetex / Description.md
Last active March 2, 2024 03:12
Serilog (C#): How to get current MethodName, FileName/Path and LineNumber without reflection

Serilog (C#): How to get the current MethodName, FileName/Path and LineNumber without reflection

This is a simple setup for reflectionless logging with serilog using caller information (and a single static class).

See also https://stackoverflow.com/a/46905798

Log.cs

Create your own Log.cs in your Root-Namespace (you can use the class below).

This class is required to detect where the call is coming from; it uses Caller-Information to speed up the program execution, because the attributes are resolved at compile-time.

static bool WaitAll(Task[] tasks, int timeout, CancellationToken token)
{
var cts = CancellationTokenSource.CreateLinkedTokenSource(token);
foreach (var task in tasks)
{
task.ContinueWith(t => {
if (t.IsFaulted) cts.Cancel();
},
cts.Token,
@IvanZuy
IvanZuy / Keil.gitignoe
Created January 5, 2014 04:43
.gitignore for Keil project.
*.axf
*.htm
*.Inp
*.map
*.tra
*.dep
*.__i
*.crf
*.d
*.o