Solved

A better logging class

Posted on 2003-11-07
8
334 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 50 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 clear a vector as well as how to detect empty vectors in C++.

685 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