Working under the hood

Published April 01, 2008
Advertisement
I spent most of my available time this past week working on not-so-glorious pieces of code. You know the ones that don't immediately pay off, but can save you huge amounts of time down the road. The first of these pieces was a logging class. I wanted something simple, relatively transparent, and able to produce readable output. Here is what I ended up with.

Simple
  • Consists of two classes, one encapsulating a log and another encapsulating an object that wants to use the log
  • Few but meaningful options, including indent, message type, contexts
Transparent
  • Not much to explain here, just wanted to leave as small of a footprint inside my code as possible.
Readable
  • HTML output
  • Alternating row background color
  • Context markers

Here is the code:

AppLogger.h
AppLogger.cpp

Here is a screenshot showing some log output



The second piece of under-the-hood code is a generic object factory based on an article I read here at GameDev. I am using it to load objects from my level files and it seems pretty cool thus far.

I also got my hands dirty doing some XML parsing using TinyXml. This turned out to be pretty simple and I would recommend it to anyone wanting fast, basic XML capabilities in their C++ app.

I have also switched gears and plan to use Bullet Physics. Originally I was leaning towards PhysX and I cannot pin down exactly why I changed my mind, but it was just a feeling. Anyway, it will be my first time integrating any type of physics into a game so no mater what I will come away with some knowledge.

Gamewise I have began to hammer out a level file format and am now working on parsing the files and creating appropriate objects.
0 likes 2 comments

Comments

Ravuya
Very nice logging output. Way nicer than my wad of line-broken HTML.

I eventually stopped using my log stuff altogether when I figured out I was never going back to the log file and that it was messing up my code with constant logging calls.
April 02, 2008 12:36 AM
BrianH
Thanks,

Yes, I certainly think that logs have their uses and misuses. I believe limiting log output to startup, shutdown, and critical events is probably a good idea. It is probably also good practice to enclose logging calls inside some #define blocks so that once you find yourself not going back to view the logs, you can remove the overhead easily from your code.

-brian
April 02, 2008 08:53 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement