/*========================== begin_copyright_notice ============================
Copyright (C) 2021-2024 Intel Corporation

SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/

#include <stdlib.h>
#include <iostream>
#include <string>
#include <iostream>
#include <sstream>

#include "gtreplay_assert.h"


void internalWarning(const char* msg)
{
    std::stringstream ostr;
    ostr << "GTReplay Warning: " << msg << std::endl;
    std::cerr << ostr.str();
}

void internalWarning(std::string msg)
{
    std::stringstream ostr;
    ostr << "GTReplay Warning: " << msg << std::endl;
    std::cerr << ostr.str();
}

void internalError(const char* msg,
    int line,
    const char* function)
{
    std::stringstream ostr;
    if (msg)
        ostr << "GTReplay ERROR: " << msg << std::endl;
    else
        ostr << "GTReplay ERROR !!" << std::endl;

    ostr << std::endl;
    ostr << "at: " << function << ":" << line << std::endl;

    std::cerr << ostr.str();
    exit(EXIT_FAILURE);
}

void internalError(std::string msg,
    int line,
    const char* function)
{
    std::stringstream ostr;
    ostr << "GTReplay ERROR: " << msg << std::endl;

    ostr << std::endl;
    ostr << "at: " << function << ":" << line << std::endl;
    
    std::cerr << ostr.str();
    exit(EXIT_FAILURE);
}

//void internalError(const char* expr,
//    int line,
//    const char* function)
//{
//    std::stringstream ostr;
//    if (expr)
//        ostr << "GTReplay ERROR: " << expr << std::endl;
//    else
//        ostr << "GTReplay ERROR !!" << std::endl;
//
//    ostr << std::endl;
//    ostr << "at: " << function << ":" << line << std::endl;
//
//    std::cerr << ostr.str();
//    exit(EXIT_FAILURE);
//}

void internalError(const char* expr,
    std::string msg,
    int line,
    const char* function)
{
    std::stringstream ostr;
    if (expr)
        ostr << "GTReplay ERROR: " << expr << "  " << msg << std::endl;
    else
        ostr << "GTReplay ERROR !!" << std::endl;

    ostr << std::endl;
    ostr << "at: " << function << ":" << line << std::endl;

    std::cerr << ostr.str();
    exit(EXIT_FAILURE);
}
