Scott Hanselman

NuGet Package of the Week: MarkdownLog makes log files much prettier

July 30, '14 Comments [6] Posted in NuGet | NuGetPOW
Sponsored By

While I'm not 100% gaga over Markdown as I know many of you are, I definitely appreciate it's usefulness and it's clarity. Some folks would say I shouldn't rest until every binary document on my hard drive has been converted to Markdown. I say, nay nay. That said, I totally dig MarkdownPad and you should use it every day. It's lovely.

If you don't want to install anything, check out http://dillinger.io and quickly edit some Markdown in the browser.

image

But, I digress.

Note: Be sure to check out all the NuGet packages of the week! There's more!

The general idea behind Markdown is that HTML is way too complex for 90% of what you need, so rather than <ul> and <li> and all that, why not just express bullets with asterisks? We can all get behind that. There are many other simple Markdown syntaxes that you can learn in a few minutes. Once you've created some Markdown, you can easily generate PDFs, HTML, Word Documents, whatever you like.

Recently I stumbled upon Stuart Wheelwright's article on Using Markdown for Effective Logging over at CodeProject. Here's the first image borrowed from his excellent article where he clearly shows why Markdown is simpler than HTML:

html-vs-md

Stuart has taken Markdown and created a wonderful little library called MarkdownLog. It's a brilliant little idea that one of us should have come up with first! Kudos to Stuart. ;)

[MarkdownLog] is designed to make it trivial to produce Markdown formatted text from an application's data structures. Using just one line of code, a collection of .NET objects can be output as a table or list. And, because the output is Markdown, it can later be converted to HTML for publishing, if needed.

Even better, MarkdownLog is a Portable Class Library (PCL) and can be used with any .NET platform, including iOS with Xamarin. In fact, it's an iPhone app written with Xamarin that compelled Stuart to write MarkdownLog.

Here's one of his first examples. This C# code:

var myStrings = new[] { "John", "Paul", "Ringo", "George" };
Console.Write(myStrings.ToMarkdownBulletedList());

Gives you this simple Markdown.

   * John
* Paul
* Ringo
* George

At this point, you are likely unimpressed. But wait! There's more! There's a whole series of nice extension methods that make it easy to create templates from objects of any shape. Here's another example of his:

var data = new[]
{
new{Name = "Meryl Streep", Nominations = 18, Awards=3},
new{Name = "Katharine Hepburn", Nominations = 12, Awards=4},
new{Name = "Jack Nicholson", Nominations = 12, Awards=3}
};

Console.Write(data.ToMarkdownTable());

This gives you a Markdown table, of course. This looks nothing like an HTML table, but remember, Markdown is source code that can be translated into other formats like HTML and PDF.

 Name              | Nominations | Awards
----------------- | -----------:| ------:
Meryl Streep | 18 | 3
Katharine Hepburn | 12 | 4
Jack Nicholson | 12 | 3

Be sure to explore the full CodeProject article and the home page for MarkdownLog. Think about how you could add this to your existing logging framework and create better logs for tests, builds, anything. Take a look at the HTML render of one of Stuarts's Test Suite Runs and tell me that you want immediately want to get to work updating your old .LOG files.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Wednesday, July 30, 2014 4:57:58 PM UTC
WebEssentials has some nice Markdown features too.
http://vswebessentials.com/features/markdown
Andrew Coats
Wednesday, July 30, 2014 6:10:47 PM UTC
While I see the use of Markdown for things like code blocks with syntax highlighting, I don't see the benefit for simple cases like lists and tables. In fact, authoring a table in Markdown syntax seems way more annoying than writing the equivalent HTML.
Sam
Sunday, August 17, 2014 5:08:59 PM UTC
You can consume the polk salad leaves that way, or drain and toss
in a skillet using a couple of teaspoons of bacon drippings and stir fry them for about one minute.
For mild to moderate psoriasis, topical creams will be the treatments of choice.

Acai berry contains important antioxidants called Anthocyanins which eradicate toxins within us to keep the body
functioning. The five leaves on each stem should really symbolize the elements in perfect harmony.



Last week I met among my friend, He is also a fantastic article writer and write articles
for a number of web development companies.
Make each paragraph intriquing, notable and appealing with a fresh supportive idea
which could possibly be a connecting link to the idea in the previous paragraph.
Phytolacca decandra whether ([mcpvp.zendesk.com](https://mcpvp.zendesk.com/entries/51978950-Fraud-Deceptions-And-Downright-Lies-About-Effective-Is-Phytolacca-Berry-s-Mother-Tincture-Exposed "mcpvp.zendesk.com")) You don't need to be an highest rated writer to write down effectively to the
extent of having your individual original articles published on article directories for the internet.
You can, as an example, choose to create about your role model and just how he
or she has helped you deal together with your disability.
Wednesday, October 15, 2014 11:06:43 PM UTC
Every weekend i used to paay a vijsit this web page, for the reason that i wish ffor enjoyment, as this this web
site conations truly pleasant funny material too.


My web blog; [porn membership evaluations](http://pornmau5.com/blog/8 "porn membership evaluations")
Friday, October 17, 2014 2:50:21 AM UTC
It should be taken the whole year, before and after
the workout program is done, as well as at the start of the day and
during those days when you are not in the gym. Then bending at
the knees and hips you lower the barbell down until your thighs are almost parallel to
the floor. Bodybuilding nutrition is quite simple, there are Proteins Carbohydrates and fats and your
nutrition approach would need to contain balance of all, siding with slightly more protein to recover and gain the muscle.


Also visit my page no nonsense muscle building guide
discount ([to.ly](http://to.ly/DsnB "to.ly"))
Friday, October 17, 2014 3:16:21 PM UTC
Omega-3s help your body to burn off calories before they get stored as fat.
Vegetarian Weight Loss Food #4 - Cucumber. So take a step further and generally improve your physical
condition through the effective and reliable Nutrilean dietary
supplements.

my homepage; the jump manual ([heartmom.co.kr](http://heartmom.co.kr/xe/freeboard/623719 "heartmom.co.kr"))
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.