Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #pragma once
  2. #include <windows.h>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <time.h>
  7.  
  8.  
  9. //=============================================================================================================
  10.  
  11.  
  12. #define DbgMsg DbgWrite
  13.  
  14.  
  15. //=============================================================================================================
  16.  
  17.  
  18. void DbgWrite( const char *fmt, ... )
  19. {
  20.     static bool bFirstTime = true;
  21.     if( bFirstTime )
  22.     {
  23.         std::remove( "C:\\asd.txt" );
  24.         bFirstTime = false;
  25.     }
  26.  
  27.     time_t rawtime;
  28.     time( &rawtime );
  29.     struct tm *timeinfo = localtime( &rawtime );
  30.     char szTime[64];
  31.  
  32.     strftime( szTime, sizeof(szTime) - 1, "[%H:%M:%S] ", timeinfo );
  33.  
  34.     va_list va_alist;
  35.     char szBuffer[2048];
  36.  
  37.     va_start( va_alist, fmt );
  38.     _vsnprintf_s( szBuffer, sizeof(szBuffer), sizeof(szBuffer) - 1, fmt, va_alist );
  39.     va_end( va_alist );
  40.  
  41.     std::string buf( szBuffer );
  42.     buf.insert( 0, szTime );
  43.  
  44.     OutputDebugStringA( buf.c_str() );
  45.  
  46.     std::ofstream f( "C:\\asd.txt", std::ios_base::out | std::ios_base::app );
  47.     f << buf << std::endl;
  48.     f.close();
  49. }
  50.  
  51.  
  52. //=============================================================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement