Skip to content

Latest commit

History

46 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Contextually

Enables contextual information to flow with your code:

usingSystem;usingContextually;namespaceSample{classApp{staticvoidMain(string[]args){// Setup top level context of the entire app.varsystemContext=newNameValueCollection{["MachineName"]=System.Environment.MachineName};using(Relevant.Info(systemContext)){// Shows that the context flows even if you start a new thread.Task.Run(AppMainLoop).Wait();}// This is the end of the context scope.}voidAppMainLoop(){Console.WriteLine("Enter your name:");varuserName=Console.ReadLine();varappContext=newNameValueCollection{["UserName"]=userName};// Setup a sub-context of relevant information.using(Relevant.Info(systemContext)){while(...)DoWork();}// End of the sub-scope. The "UserName" is not// available anymore, but 'MachineName' still is.}voidDoWork(){try{
...}catch(Exceptionex){// Now you can collect all contextual information// from all open scopes and sub-scopes.varaggregatedContext=Relevant.Info();// This helps with analysis of 'dynamic' data,// which is not known at compile time.Logger.LogError(ex,aggregatedContext);}}}}

About

A dead simple contextual block pattern library that works, even with async/await and threads.

Topics

Resources

Stars

9 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages