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 August 7, 2024 01:57
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 September 18, 2024 02:25
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