11.5. Logging

 <  Day Day Up  >  

In pre-object days, I was adamant about having only a single return point for a routine. The return value could be logged before exiting the routine. With object-oriented code, my adamancy for a single return has dissipated. I can always add logging to a method with a proxy, as shown in this chapter. The calls to logging do not then intrude upon the logic for normal operations. The logging proxy can record the values of the input parameters and the return value.

LOGS ARE USEFUL

In the Cold War days, the United States built an antimissile defense system. The radar for this system used a phased-array antenna. A phased-array antenna moves its beam by electrical signals rather than mechanical means (the rotating antenna you see on ships and other places). This permits the antenna to track multiple objects in the sky. The idea was that the system could track an enormous number of incoming missiles, determine their flight path , and then launch missiles to intercept the incoming ones and blow them up. Needless to say, the system was rather complex. There was no possible way to test the entire system. It would have been expensive to launch 50 missiles against it on a similar trajectory to those expected to come from Russia.

A story that was going around at the time suggested building a huge underground bunker. In the bunker would be thousands of tape drives. When the attack came, the tape drives would log all the information from the antenna and the software. Then in 100,000 years , when civilization had rebuilt itself to the point where it was creating a new antimissile system, humans could examine the logs on those tapes and eliminate in the next version of the system the bugs that had been recorded.


Unit tests, or system use case tests, can check a system's functionality. However, these tests do not check a system in real life. Real users can generate sequences of operations or values of data not covered by automated tests. The interaction of modules in a multithreaded or multiprocess environment can be difficult to determine. Logging at major interfaces can provide the information needed to debug errors.

PLAN YOUR LOGGING STRATEGY

Determine where and how you are going to log .


 <  Day Day Up  >  


Prefactoring
Prefactoring: Extreme Abstraction, Extreme Separation, Extreme Readability
ISBN: 0596008740
EAN: 2147483647
Year: 2005
Pages: 175
Authors: Ken Pugh

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net