home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2002 April / Game.EXE_04_2002.iso / Alawar / TxtLog.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-02-20  |  933 b   |  50 lines

  1. #include "TxtLog.h"
  2. #include "String.h"
  3.  
  4. TxtLog::~TxtLog()
  5. {
  6.     if( file )
  7.     {
  8.         fputs( "---------------------Loging stopped------------------------------\n", file );
  9.         fclose( file ); file = 0;
  10.     }
  11. }
  12.  
  13. void TxtLog::warning(const String & str)
  14. {
  15.     if( file )
  16.     {
  17.         fprintf( file, "----Warning----: %s\n", (const char *)str );
  18.         fflush( file );
  19.     }
  20. }
  21.  
  22. void TxtLog::message(const String & str)
  23. {
  24.     if( file )
  25.     {
  26.         fputs( (const char *)str, file );
  27.         fflush( file );
  28.     }
  29. }
  30. void TxtLog::error(const String & str)
  31. {
  32.     if( file )
  33.     {
  34.         fprintf( file, "-----Error-----: %s\n", (const char *)str );
  35.         fflush( file );
  36.     }
  37. }
  38.  
  39. TxtLog::TxtLog(const String & fname, const String & header)
  40. :    file( fopen( (const char *)fname, "wt" ) )
  41. {
  42.     if( file )
  43.     {
  44.         fputs( header, file );
  45.         fputs( "\n", file );
  46.         fputs( "---------------------Loging started------------------------------\n", file );
  47.         fflush( file );
  48.     }
  49. }
  50.