Razor Code
Rambling about code since quite recently

Topics

User Functions





    Don't have an account yet? Sign up as a New User
    Lost your password?

Events

There are no upcoming events

Older Stories

Sunday 14-Sep

  • ACM ICPC 2008 (0)

  • Monday 11-Aug

  • NZ Programming Comp (0)

  • Sunday 27-Jul

  • Blast from the past (0)

  • Monday 21-Jul

  • Timetable generator again (0)

  • Tuesday 08-Jul

  • Hosting (2)

  • Saturday 05-Apr

  • Sparse Volume (0)

  • Friday 28-Mar

  • Carmack (0)

  • Tuesday 04-Mar

  • Back to Uni (0)
  • Dell Kill Switch Direct (0)

  • Monday 18-Feb

  • Lappy (0)

  •  Logging    
     Author: 
     Dated:  Monday, July 13 2009 @ 03:15 AM NZST
     Viewed:  74 times  
    Programming

    So I've just been writing a contender for the most overkill logging system known to man. You see, with my "spare time" projects, I have a tendency to not do anything that doesn't stretch my programming muscles a bit. It's great to do something tricky after watching your skills atrophy for an entire semester. So, when I decide it's time to replace all my cout logging with something a bit tidier, it's not enough to just write them to a file. That would be boring. The task has to become complicated enough to retain my interest.

    With that in mind, I based my solution on two articles: Using XML Technologies For Enhancing Log Files and Simple STL Logging System (which is basically about boost streams). By combining these, I end up with an xml logging system which is written to like a standard stream. It's a macro, admittedly, but there's nothing you can do about that while keeping file/function/line information. I have yet to do the xslt part, but most of it is in place, in a rough form.

    Along the way, I came up with the idea of a logged exception. A logged exception is basically just a shortcut for logging an error, then throwing an exception, and using the same message for both. This allows the calling code to catch and handle the exception if it wants, but if it is not handled or handled badly then you still have a handy message in the log so you know where things went wrong.




    Trackback

    Trackback URL for this entry: http://razorcode.net/trackback.php/Logging

    No trackback comments for this entry.
    Logging | 0 comments | Create New Account
    The following comments are owned by whomever posted them. This site is not responsible for what they say.