473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Logging Mechanism in C++

Hello
I want to do some debugging stuff for my C++ program.
I want to have some mechanism by which I can pring function names at
runtime.
like
void function ()
{
LogMessage();
}

This LogMessage function should automatically take filename ( which is
possible using __FILE__ and line number using __LINE__ )
but how to get function name at runtime.

Thanks in Advance.
Avinash

Jul 22 '05 #1
5 1716
Avinash wrote:
Hello
I want to do some debugging stuff for my C++ program.
I want to have some mechanism by which I can pring function names at
runtime.
like
void function ()
{
LogMessage();
}

This LogMessage function should automatically take filename ( which is
possible using __FILE__ and line number using __LINE__ )
but how to get function name at runtime.

Thanks in Advance.
Avinash


I'm not sure whether this is compiler specific, but I have written a
debugging mechanism for VC++ compilers some time ago, and I remember I used
__FUNCTION__ to log which function I'm currently debugging.

Regards,
Matthias
Jul 22 '05 #2
have a look at log4cplus

Johan
"Matthias Käppler" <no****@digitalraid.com> schreef in bericht
news:cp*************@news.t-online.com...
Avinash wrote:
Hello
I want to do some debugging stuff for my C++ program.
I want to have some mechanism by which I can pring function names at
runtime.
like
void function ()
{
LogMessage();
}

This LogMessage function should automatically take filename ( which is
possible using __FILE__ and line number using __LINE__ )
but how to get function name at runtime.

Thanks in Advance.
Avinash


I'm not sure whether this is compiler specific, but I have written a
debugging mechanism for VC++ compilers some time ago, and I remember I
used
__FUNCTION__ to log which function I'm currently debugging.

Regards,
Matthias

Jul 22 '05 #3
Matthias Käppler wrote:
Avinash wrote:
This LogMessage function should automatically take filename ( which
is possible using FILE and line number using LINE )
but how to get function name at runtime.

I'm not sure whether this is compiler specific, but I have written a
debugging mechanism for VC++ compilers some time ago, and I remember
I used __FUNCTION__ to log which function I'm currently debugging.

That's not a standard preprocessor identifier (it's gcc, I think). As
of the new C standard, the equivalent there is __func__. I don't know
whether C++ is in the process of adopting that or not.


Brian
Jul 22 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Avinash wrote:
Hello
I want to do some debugging stuff for my C++ program.
I want to have some mechanism by which I can pring function names at
runtime.
like
void function ()
{
LogMessage();
}

This LogMessage function should automatically take filename ( which is
possible using __FILE__ and line number using __LINE__ )
but how to get function name at runtime.
Have a look at Boost's test facility at
http://www.boost.org/libs/test/doc/index.html
Thanks in Advance.
Avinash


Evan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBwMChpxCQXwV2bJARAkkrAJ9E1Agm0hS+496vCsHfo7 XTQuf5RACdFwg2
+wg6xm59Hpu/1Y6/bPcPRXs=
=y/Pz
-----END PGP SIGNATURE-----
Jul 22 '05 #5
Default User wrote:
That's not a standard preprocessor identifier (it's gcc, I think). As
of the new C standard, the equivalent there is __func__. I don't know
whether C++ is in the process of adopting that or not.


I used it with Microsoft Visual C++ 7. So it's probably not gcc specific,
but it may not be standard conformous either.
Does the C++ standard define any preprocessor makros at all? I thought that
would be a compiler/implementation thing.
Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: JT | last post by:
i have a text file that is used as a logfile for easier debugging. i am using the OpenTextFile method to write to this file. this method exists inside a logging function that can be called from...
1
by: Gram | last post by:
Hello, Can anoyone help me with the following: I have a application online using ASP in which users log in and log out. However, a lot of users simply close the window, bypassing my log-out...
4
by: Navin Mishra | last post by:
Hi, Does someone has an example of logging in a different thread ? Native Windows API had a mechanism to send thread message(which could be used to send a message with log data details). Does...
6
by: idesilva | last post by:
Hi, I have an application which sends/receives messages at a very high rate. This app needs to 'log' the contents of these messages. Since the msg rate is high, 'logging' each and every msg to a...
6
by: Kevin Jackson | last post by:
Let's say we log exceptions to the windows application event log using the Exception Management Application Block. Is there a pattern that can be used so the exception is logged only once and not...
16
by: Einar Høst | last post by:
Hi, I'm getting into the Trace-functionality in .NET, using it to provide some much-needed logging across dlls in the project we're working on. However, being a newbie, I'm wondering if some...
3
by: Oscar Thornell | last post by:
Hi, I am thinking about doing all my logging asynchronously using a delegate. The main resaon for this would be performance and responsiveness of the application (an ASP.NET app). //Exampel...
0
by: vineetkumar | last post by:
dear all, i have a problem to maintain the Transaction Logging Mechanism in postgresql 8.1 so please send reply how i can maintain Rollback Segment, LogFiles, and every day transaction file . is...
9
by: Rasika WIJAYARATNE | last post by:
Hi guys, Please check this out: http://rkwcoding.blogspot.com/2007/07/error-logging.html
6
by: Vyacheslav Maslov | last post by:
Hi all! I have many many many python unit test, which are used for testing some remote web service. The most important issue here is logging of test execution process and result. I strongly...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.