home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 08 - 1992 / 08.07 Nov⁄Dec 92 / Function Logging / Code / LogTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-27  |  1.3 KB  |  84 lines  |  [TEXT/KAHL]

  1. /*
  2.     LogTest.c - A simple test of the logging system.
  3. */
  4.  
  5. #include "LogToFile.h"
  6. #include <Memory.h>
  7. #include <QuickDraw.h>
  8. #include <Fonts.h>
  9. #include <Windows.h>
  10. #include <Menus.h>
  11. #include <TextEdit.h>
  12. #include <Dialogs.h>
  13. #include <OSEvents.h>
  14.  
  15. /*
  16.     This #pragma indicates that all functions in this file will be logged.
  17.     You can move it to a single routine to log just that routine.
  18.         #pragma options( profile, force_frame )
  19.  
  20.     The opposite of this command is:
  21.         #pragma options( !profile, !force_frame ) 
  22. */
  23. #pragma options( profile, force_frame )
  24.  
  25. /*
  26.     Prototypes
  27. */
  28. void    InitMacToolbox( void );
  29. void     DoSomething( void );
  30. void     Func1( void );
  31. short     Func2( short x );
  32.  
  33.  
  34. main()
  35. {
  36.     InitMacToolbox();
  37.     
  38.         // initialize the logging system
  39.     LogInit( NULL,         // default file location
  40.             true,         // delete the old file
  41.             false,         // don't flush the volume all the time
  42.             true );        // start logging
  43.     
  44.         // call a few routines
  45.     DoSomething();
  46.  
  47.         // close the log file
  48.     LogDInit();    
  49. }
  50.  
  51.  
  52. void DoSomething( void )
  53. {
  54.     Func1();
  55.     Func2( 10 );
  56. }
  57.  
  58. void Func1( void )
  59. {
  60.     static short    x = 0;
  61.     if ( ++x < 2 )
  62.         Func1();
  63. }
  64.  
  65. short Func2( short x )
  66. {
  67.     return( 2 * x );
  68. }
  69.  
  70. static void InitMacToolbox( void )
  71. {
  72.     MaxApplZone();
  73.     MoreMasters(); MoreMasters();
  74.     InitGraf( &qd.thePort ); 
  75.     InitFonts();
  76.     InitWindows();
  77.     InitCursor();
  78.     InitMenus();
  79.     InitDialogs( 0L );
  80.     TEInit();
  81.     FlushEvents( -1, 0 );    
  82. }
  83.  
  84.