[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

A better logging class

Posted on 2003-11-07
8
Medium Priority
?
357 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:funvill
  • 3
  • 3
  • 2
8 Comments
 
LVL 3

Expert Comment

by:Kashra
ID: 9705468
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.
0
 
LVL 3

Accepted Solution

by:
Kashra earned 200 total points
ID: 9705472
0
 
LVL 2

Author Comment

by:funvill
ID: 9705490
Perfect thank you so much
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:Sandra-24
ID: 9711063
Hey funvill I could use a logging function like that, would you like to share your code with me?
0
 
LVL 2

Author Comment

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

0
 
LVL 2

Author Comment

by:funvill
ID: 9712088
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
0
 
LVL 3

Expert Comment

by:Sandra-24
ID: 9726376
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
0
 
LVL 3

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question