Managed World

Techno-babble from yet another babbler RSS 2.0
# Saturday, July 09, 2005

Personally, I think logging is something that is often overlooked by hobbyist developers. I personally have found good logging at work to help tremendously. So, whenever I get a chance, I like to try to do "The Right Thing" on my home projects.

When developing games, I think it is especially important to be able to get insight into the application while it's running. Sometimes you need to poke under the hood and see how the ole' girl is running, right? Well, in that vein, I hooked up my logging system for the game engine a couple of days ago (I should say, I hooked up my *viewer* a couple of days ago because I've been logging since day one (then again, what good is a log if it's never used, eh?)).

First of all, I had to make a few decisions when building my logging framework. Whenever possible, I like to avoid rolling my own. Call me old or pr3t3nd3r or whatever you young kids do these days, but I happen to enjoy spending my time doing the important things, rather than re-inventing the wheel. With that in mind, I decided to piggy-back on the existing framework that's already in place for Trace. All I had to do was write a custom Trace listener (and the only reason I did that is I wanted some custom formatting) and add it to Trace. Then throughout my application when I want to log messages, I simply write them to Trace. The code doesn't know anything about a logging framework whatsoever (well, sort of, it does introduce a dependency on Trace which I'm using *as* a logging framework; so I suppose you could semantically argue that it does know about the logging framework).

By hooking onto Trace, I can also reuse all the functionality that is already in place. For instance, if I want to log to both a log file, and an in-game log viewer, no problem, just add two listeners. I'm rather proud of this (I don't know why, perhaps the simple things are the things that make me happy), so I figure I'd share what it looks like. As you will notice, my log file is color-coded. That is achieved by using an application called BareTail (it's absolutely free of charge and no install necessary). I was exposed to this at work and have been using it since in my personal projects. You can change the coloring of different lines based on "keywords" that exist within the line.

And a close up of what a snippet of the log actually says:

Any of you hobbyist game developers out there, I HIGHLY suggest you hook in a logging system if you haven't already. Trust me (or don't if you wish (although I would have a few choice words for you in THAT situation)), it will really help you gain an insight into what's happening when (although you should largely know this already). It's almost a form of "eXtreme Debugging" for game developer (a term I believe originally coined by Andre Le Mothe in the game development sense).

 #       Comments [4]
Saturday, July 09, 2005 10:22:19 PM (Pacific Standard Time, UTC-08:00)
Color coding your trace output is a great idea... really makes the info jump out at you. I'm not familiar with BareTail... does it support changing just a portion of the text, or perhaps just the foreground color? The bands of background color seem to have a sizzling effect upon my corneas. :)
Tuesday, July 12, 2005 4:38:10 PM (Pacific Standard Time, UTC-08:00)
I'm not sure if it supports just the text position. Yes, it does support just the foreground color. Unfortunately, I don't believe there is a "custom" color picker, so you might have to live with their choices for colors. The biggest reason I use the differing background colors is to prepare for Code Camp since it's a more visible difference. If it was just for me, I would definitely make it more subtle.
Sunday, July 17, 2005 7:37:52 PM (Pacific Standard Time, UTC-08:00)
That's realy nice - something I think almost every program is missing is good error checking and good logging. I'm looking forward to the next source code release!
Monday, November 28, 2005 3:26:20 AM (Pacific Standard Time, UTC-08:00)
There are some disputable moments in your article. I do not absolutely agree with the author.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Live Comment Preview

Contact

Email Me Send mail to the author(s)

Calendar

<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

About this site

Jason Olson's thoughts on Programming, Games, Music and Life in General

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

© Copyright 2008
Jason Olson

Sign In
All Content © 2008, Jason Olson
Theme based on 'Business' created by Christoph De Baene (delarou)