Link to home
Start Free TrialLog in
Avatar of funvill
funvillFlag for Canada

asked on

A better logging class

hello
I’m trying to make myself a better logging class, I got all the basic down and it works adequately and i getting ready to add the advances features...
i am using Visual studio 6, NOT vs.net

i was wondering how i would show the function that the log() function was called from
ie:  [CFooClass::FooMethod()]
and from what file and line it came from.
ie:  [File: C:\cpp\logy\log.cpp line: 195]

in the end i want something like this.
ie
[Fri Nov 07 15:48:38 2003] [File: C:\cpp\logy\log.cpp line: 195] [CFooClass::FooMethod()] this is an error message

i see this done in .net
http://www.codeproject.com/managedcpp/smartlog.asp
and in a lot of other games and appz when they crash.
So It must be possible
Avatar of Kashra
Kashra

Well, I use VC .NET, but I'd assume that VC 6 should also have the ANSI standard macros for determining filenames.

__DATE__
__FILE__
__LINE__
__STDC__
__TIME__
__TIMESTAMP__

If you use those in your code, the compiler should recognize them. If not, then try to use a compiler flag to force ANSI compliance. I know VC6 isn't very compliant in comparison to .NET, but this seems simple enough.
ASKER CERTIFIED SOLUTION
Avatar of Kashra
Kashra

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of funvill

ASKER

Perfect thank you so much
Hey funvill I could use a logging function like that, would you like to share your code with me?
Avatar of funvill

ASKER

ya sure just give me a day to document it, so you don’t have to go searching thou my code

Avatar of funvill

ASKER

Still working a few things but it works
http://downloads.funvill.com/stuff/logy_v0.01aA.zip

E-mail me with comments or suggestions
if you are using .net use this
http://www.codeproject.com/managedcpp/smartlog.asp
its done better then mine
Looks good, thanks funvill. If i make any changes to it or have any comments I'll e-mail you.

Only one nitpick, flages is actually spelled flags:) But that is easily fixed with a search and replace.

Otherwise *deletes her own log function* it looks very good. Thanks for sharing.

What sort of project are you working on as a matter of interest?

-Sandra
Oh now I see flages is a seperate thing from flags:) I thought your english was too good for a simple error like that!