Solved

A better logging class

Posted on 2003-11-07
8
320 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now