Home > View Post

Exciting changes afoot in Ukadc.Diagnostics

OK, so the project went quiet for a while but Morgan and I have been revisiting Ukadc.Diagnostics just recently and have some exciting changes on the way.

The first one, first cut of which was checked in today was an enhancement to the existing Token System of which we were already quite proud. Apart from being a great extensibility point (you can easily create your own PropertyReaders and register them as Tokens) they also make using listeners in System.Diagnostics easier, more fun and reach places other beers can't.

The latest enhancement is the option to add a 'format string' to your token. Take this example configuration for our very own ConsoleTraceListener:

<add type="Ukadc.Diagnostics.Listeners.ConsoleTraceListener, Ukadc.Diagnostics"
    initializeData="{DateTime}: {Id}, {Source}, {Message}" />

Unlike the ConsoleTraceListener that ships with System.Diagnostics, Ukadc.Diagnostics' version gives you control of the output thanks to Tokens. However, at present you're at the will of the system to format that {DateTime} token for you. You could use some of the more specific date-part tokens like so:

<add type="Ukadc.Diagnostics.Listeners.ConsoleTraceListener, Ukadc.Diagnostics"
    initializeData="{Year}-{Month}-{Date} {Hour}:{Minute}:{Second}.{Millisecond}: {Id}, {Source}, {Message}" />

A bit messy and you still don't have enough control: 12/24 hour format, 2 or 4 digit year? Not anymore...

The new way

The new format string is applied to a token like so:

{TokenName:FormatString}

So the example above could look like so:

<add type="Ukadc.Diagnostics.Listeners.ConsoleTraceListener, Ukadc.Diagnostics"
    initializeData="{DateTime:yyyy-MM-dd HH:mm:ss.fff}: {Id}, {Source}, {Message}" />
    

Now that's much better! And you can apply a format to any token you like (don't worry, it'll be ignored where it doesn't make any sense).

There's more in the wings too, including:

  • Another improvement to the token system - more on this soon
  • A new and very, very cool listener
  • Some of the listeners we promised a while back
  • There's even a contributor we're hoping to get involved
  • And, perhaps most importantly, there's a HUGE improvement coming to the documentation.
Stay tuned.

 
Josh Post By Josh Twist
11:14 AM
25 Jun 2009

» Next Post: Silverlight Validation and ViewModel
« Previous Post: Using Binding to position a Collection of elements - Take 2

Comments are closed for this post.

© 2005 - 2017 Josh Twist - All Rights Reserved.