Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __LOG_H__
- #define __LOG_H__
- #include "common.h"
- #define BLACK 0
- #define BLUE 1
- #define GREEN 2
- #define CYAN 3
- #define RED 4
- #define MAGENTA 5
- #define BROWN 6
- #define LIGHTGREY 7
- #define DARKGREY 8
- #define LIGHTBLUE 9
- #define LIGHTGREEN 10
- #define LIGHTCYAN 11
- #define LIGHTRED 12
- #define LIGHTMAGENTA 13
- #define YELLOW 14
- #define WHITE 15
- #define BLINK 128
- #define LOGFILE "InternalServer.log"
- class Log
- {
- public:
- static void SetConsoleTextColor( uint8_t color )
- {
- SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), color );
- }
- static void Error( const char* calledBy, const char* line, ... )
- {
- while( working ) Sleep( 10 );
- working = true;
- FILE *fp = fopen( LOGFILE, "a+" );
- char time[ 9 ];
- char logline[ 1024 ];
- _strtime( time );
- SetConsoleTextColor( DARKGREY );
- printf( "%s", time );
- fprintf( fp, "%s", time );
- SetConsoleTextColor( LIGHTRED );
- printf( " D " );
- fprintf( fp, " D " );
- SetConsoleTextColor( WHITE );
- printf( "%s: ", calledBy );
- fprintf( fp, "%s: ", calledBy );
- SetConsoleTextColor( LIGHTRED );
- va_list argumentList;
- va_start( argumentList, line );
- vsnprintf( logline, 1024, line, argumentList );
- va_end( argumentList );
- printf( "%s\n", logline );
- fprintf( fp, "%s\n", logline );
- fclose( fp );
- working = false;
- }
- static void Debug( const char* calledBy, const char* line, ... )
- {
- while( working ) Sleep( 10 );
- working = true;
- FILE *fp = fopen( LOGFILE, "a+" );
- char time[ 9 ];
- char logline[ 1024 ];
- _strtime( time );
- SetConsoleTextColor( DARKGREY );
- printf( "%s", time );
- fprintf( fp, "%s", time );
- SetConsoleTextColor( LIGHTCYAN );
- printf( " D " );
- fprintf( fp, " D " );
- SetConsoleTextColor( WHITE );
- printf( "%s: ", calledBy );
- fprintf( fp, "%s: ", calledBy );
- SetConsoleTextColor( LIGHTCYAN );
- va_list argumentList;
- va_start( argumentList, line );
- vsnprintf( logline, 1024, line, argumentList );
- va_end( argumentList );
- printf( "%s\n", logline );
- fprintf( fp, "%s\n", logline );
- fclose( fp );
- working = false;
- }
- static void Trace( const char* calledBy, const char* line, ... )
- {
- while( working ) Sleep( 10 );
- working = true;
- FILE *fp = fopen( LOGFILE, "a+" );
- char time[ 9 ];
- char logline[ 1024 ];
- _strtime( time );
- SetConsoleTextColor( DARKGREY );
- printf( "%s", time );
- fprintf( fp, "%s", time );
- SetConsoleTextColor( LIGHTGREEN );
- printf( " T " );
- fprintf( fp, " T " );
- SetConsoleTextColor( WHITE );
- printf( "%s: ", calledBy );
- fprintf( fp, "%s: ", calledBy );
- SetConsoleTextColor( LIGHTGREEN );
- va_list argumentList;
- va_start( argumentList, line );
- vsnprintf( logline, 1024, line, argumentList );
- va_end( argumentList );
- printf( "%s\n", logline );
- fprintf( fp, "%s\n", logline );
- fclose( fp );
- working = false;
- }
- static bool working;
- };
- #endif /* __LOG_H__ */
Add Comment
Please, Sign In to add comment