home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Examples / MiscLogFile / LogFileTest.m next >
Encoding:
Text File  |  1994-01-06  |  1.6 KB  |  47 lines

  1. //
  2. // LogFileTest.m -- test out the log file class
  3. //        Written by Don Yacktman (c) 1993 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This program is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. #import <misckit/misckit.h>
  15. #import <appkit/appkit.h>
  16. #import <stdio.h>
  17.  
  18. void main()
  19. {
  20.     id logFile = [[MiscLogFile alloc] init];
  21.     id theLine = [[MiscString alloc] init];
  22.     int i;
  23.     [logFile setFileName:[[MiscString alloc] initString:"sample.log"]];
  24.  
  25.     [theLine setStringValue:"This is the first line.\n"];
  26.     [logFile addLineToLogFile:theLine];
  27.     [theLine setStringValue:"Repeat this line four times.\n"];
  28.     [logFile openFile];
  29.     for (i=0; i<4; i++) [logFile appendToLogFile:theLine andFlush:NO];
  30.     [theLine setStringValue:"Repeat this line twice.\n"];
  31.     [logFile appendToLogFile:theLine andFlush:NO];
  32.     [logFile appendToLogFile:theLine andFlush:NO];
  33.     [logFile closeFile];
  34.     [theLine setStringValue:"Repeat this new line twice.\n"];
  35.     [logFile openFile];
  36.     [logFile appendToLogFile:theLine andFlush:NO];
  37.     [logFile appendToLogFile:theLine andFlush:NO];
  38.     [theLine setStringValue:"And this line three times.\n"];
  39.     for (i=0; i<3; i++) [logFile appendToLogFile:theLine andFlush:YES];
  40.     [logFile closeFile];
  41.     [theLine setStringValue:"This is the last line.\n"];
  42.     [logFile addLineToLogFile:theLine];
  43.     system("cat sample.log");
  44.     
  45.     exit(0);
  46. }
  47.