How to save my own debugging lines without checking them?

When working on some code, I add additional debugging protocols to make it easier for me to track the status and values ​​that concern me for this particular fix.

But if I checked this in the source code repository, my colleagues would get mad at me for polluting the output of the log and polluting the code.

So, how do I locally save these lines of code that are important to me without checking them?

Explanation: Many answers are related to the output of the log, and that you can filter this with the log levels. And I agree with that.

But. I also mentioned the problem of pollution of the actual code. If someone puts a log statement between any other lines of code, the value of all variables is printed all the time. It really makes the code hard to read. So I really would like to avoid this. Basically, without checking the registration code at all. Therefore, the question arises: how to keep your own lines of the magazine for special purposes. Therefore, you can use them for your debug builds without cluttering up the tested code.

+5
source share
10 answers

, , - . , . .

, . , , . , , , , . , , "" .

, , , , , .

+4

, .

, Log , . , - !

+3

(, )?

#if DEBUG
    logger.debug("stuff I care about");
#endif

, , trace debug, .

if(logger.isTraceEnabled()) {
    logger.log("My expensive logging operation");
}

, - , () .


, - , , . , .
+2

, , , , (, ​​ on) . , , , ( patch), , , patch -R ( ).

. , , , . , , C ++, C.

+2

, ...
, .

, , , , .

, . , , " ". API.

, . , , /, , , , .

, , , , .

, , , .
, -, ( ), , .

+2

? Git . , "" , .

+1

#if DEBUG #endif....

, , "", .

, , , , ....

MYDEBUGCONFIG :

#if MYDEBUGCONFIG 
...your debugging code
#endif;
+1

- :

, . .

. .

, , (, ), , !

+1

, #if. C/++ . / ConditionalAttribute. . , - , . , # if/# endif, .

0

- , , ...

,

// ##LOG-START##
logger.print("OOh A log statment");
// ##END-LOG##

, , script, .

, , .

script ...

logger.print("My Innane log message"); //##LOG

, .. . .

0

All Articles