#pragma once

#include <fstream>
#include <sstream>

#define WRITE_FILE(msg) { \
static int s_logNum = 0; \
++s_logNum; \
if (s_logNum < 30 || s_logNum % 1000 == 0) \
    { \
        logFS << "num: [" << s_logNum << "] -- " << "[" << msg << "]\n"; \
        logFS.flush(); \
    } \
}

#define CHECK_MEDIA_DATA(data) { \
    std::ostringstream os; \
    os << __FUNCTION__ << ": "; \
    if (data == nullptr) \
    { \
        os << "Check Data is null"; \
        WRITE_FILE(os.str().c_str()); \
        return ; \
    } \
    if (data->dataSize == 0 || data->bufferSize == 0) \
    { \
        os << "check data size == 0! " << "dataSize: " << data->dataSize << ", bufferSize: " << data->bufferSize; \
        WRITE_FILE(os.str().c_str()); \
        return ;  \
    } \
    os << "dataSize: " << data->dataSize << ", bufferSize: " << data->bufferSize; \
    WRITE_FILE(os.str().c_str()); \
}

#define TEST_LOG() logFS << __FUNCTION__ << ":"

static std::fstream logFS("encryptionDemoDebug.txt", std::ios::app);