mooooooooooore debug messages

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

mooooooooooore debug messages

cantcode
In LibreCAD-master/libraries/libdxfrw/src/libdxfrw.cpp
line 1770, there is:
DBG("dxfRW::processHeader\n");
but line 23-28 says
#ifdef DRW_DBG
#include <iostream> //for debug
#define DBG(a) std::cerr << a
#else
#define DBG(a)
#endif

searching for DRW_DBG resulted in no findings
So is it possible to define DRW_DBG in:

librecad/src/main/main.cpp
line ca. 99
for (int i=0; i<argc; i++) {
                if (QString("--debug") == argv[i]) {
                RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING);
                }
        }

so we can get moooooooooooooooore debugging messgages
Does that make sense?
Or is it possible to define DRW_DBG when executing LCad?
something like: librecad --debug 2  --define DRW_DBG >out.log  ???
Reply | Threaded
Open this post in threaded view
|

Re: mooooooooooore debug messages

cantcode
Is it a bad idea to change

for (int i=0; i<argc; i++) {
                if (QString("--debug") == argv[i]) {
                RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING);
                }
        }

to

for (int i=0; i<argc; i++) {
                if (QString("--debug") == argv[i]) {
                RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING);
                define DBG(a) std::cerr << a; //<--- this is the new line I wanted to be added
                }
        }

?
Reply | Threaded
Open this post in threaded view
|

Re: mooooooooooore debug messages

dxli
Hi,

I don't quite get what you want to achieve here.

if you mean:

#define DBG(a) std::cerr << a; //<--- this is the new line I wanted to be added

parsing argv[] is carried out at running time, and parsing C style macros is carried out at cpp building time.

Also, macros are not limited by scope, so the macros would be visible for lines thereafter, the if() and {} have no effect here.

Thanks,

dxli

On Tue, Jul 16, 2013 at 11:55 AM, cantcode [via LibreCAD] <[hidden email]> wrote:
Is it a bad idea to change

for (int i=0; i<argc; i++) {
                if (QString("--debug") == argv[i]) {
                RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING);
                }
        }

to

for (int i=0; i<argc; i++) {
                if (QString("--debug") == argv[i]) {
                RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING);
                define DBG(a) std::cerr << a; //<--- this is the new line I wanted to be added
                }
        }

?


If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/mooooooooooore-debug-messages-tp5708530p5708575.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org
Reply | Threaded
Open this post in threaded view
|

Re: mooooooooooore debug messages

cantcode
"I don't quite get what you want to achieve here."
I just wanted libdxfrw to print the debug messages if needed by the user of librecad.

"... parsing C style macros is carried out at cpp building time...."
Right, did not think of that. So my suggestion would not work for users which do not build librecad but just use it.

I wanted a way for the user to also enable the debug messages of libdxfrw by passing --debug to librecad or something in those lines.
Reply | Threaded
Open this post in threaded view
|

Re: mooooooooooore debug messages

dxli

it's exactly the idea of RS_Debug() class, use the debugging level control, make sure the level from argv[] is set properly, and RS_Debug() will ignore messages with lower levels.


void RS_Debug::instance()->print(RS_Debug::D_DEBUGGING, const char* format ...) ;




On Tue, Jul 16, 2013 at 3:08 PM, cantcode [via LibreCAD] <[hidden email]> wrote:
"I don't quite get what you want to achieve here."
I just wanted libdxfrw to print the debug messages if needed by the user of librecad.

"... parsing C style macros is carried out at cpp building time...."
Right, did not think of that. So my suggestion would not work for users which do not build librecad but just use it.

I wanted a way for the user to also enable the debug messages of libdxfrw by passing --debug to librecad or something in those lines.



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/mooooooooooore-debug-messages-tp5708530p5708578.html
To start a new topic under LibreCAD-dev, email [hidden email]
To unsubscribe from LibreCAD-dev, click here.
NAML



--
Dongxu Li, Ph.D.
www.librecad.org
Reply | Threaded
Open this post in threaded view
|

Re: mooooooooooore debug messages

cantcode
"it's exactly the idea of RS_Debug() class..."
I think the debug messages from libdxfrw (reading/writing dxf files) use DBG("dxfRW::processHeader\n");  for printing the messages.
So libdxfrw does not use RS_Debug() (so it can be used in other projects I think).
That's the reason I tried to find a simple way to make the DBG("") work.