Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define LOG_PREFIX "meme.dll >>"
- static std::mutex log_mutex;
- static void log_data( bool should_log_to_file, const char* fmt, ... ) noexcept {
- [[maybe_unused]] std::lock_guard<std::mutex> log_lock( log_mutex ); // @note: @es3n1n: thanks msvc for the warnings
- char tmp_buf[ 1024 ];
- va_list va;
- va_start( va, fmt );
- _vsnprintf_s( tmp_buf, 1024, fmt, va );
- va_end( va );
- char buf[ 1024 ];
- sprintf_s( buf, sizeof( buf ), "%s %s", LOG_PREFIX, tmp_buf );
- //std::printf( "%s\n", buf );
- if ( !should_log_to_file )
- return;
- std::ofstream out_stream( GLOBAL_LOG_FILE, std::ios::out | std::ios::app );
- out_stream << buf << std::endl;
- out_stream.flush( );
- out_stream.close( );
- };
- #define I( fmt, ... ) log_data( true, fmt, __VA_ARGS__ );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement