Sign in to follow this  
Racky1275

[Solved] Logging with compiler generated constants

Recommended Posts

I've got a logging system where every time I log a message I want to say where in the code that message came from. Currently I have:
Log("gfxengine.c","Initalise","Failed to set screen resolution");


Which logs... "12/10/2007 10:33:12 - gfxengine.c(Initalise) - Failed to set screen resolution" It's quite tedious having to the tell the Log routine something which the compiler should already know, where in the code we currently are. Ideally I could just use something along the lines of:
Log(__File,__Procedure,"Failed to set screen resolution");


Where the compiler fills in the details automatically. Unfortunately I can't see anything in the VS Cpp Express 2005 documentation to suggest that this feature might exist. Anyone know??? [Edited by - Racky1275 on October 12, 2007 7:31:03 AM]

Share this post


Link to post
Share on other sites
There's always the __FILE__ and __LINE__ preprocessor macros (as well as __TIME__ and __DATE__). Some compilers have extensions for getting the function name as well.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this