/**
 *  \file cc_log.c
 *  \brief common crypto core log for SWd (Mobicore & QSEE)
 *  \author Oleksii Mosolab (o.mosolab@samsung.com)
 *  \version 0.1
 *  \date Created Aug 21, 2013 7:10:14 PM
 *  \par In Samsung Ukraine R&D Center (SURC) under a contract between
 *  \par LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine) and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
 *  \par Copyright: (c) Samsung Electronics Co, Ltd 2013. All rights reserved.
**/

#ifndef CC_LOG_H
#define CC_LOG_H

#ifdef QSEE
#include "qsee_log.h"
#endif

#if defined(MOBICORE) || defined (MOBICORE_TL)
#include "tlStd.h"
#include "TlApi/TlApiLogging.h"
#endif

#if defined (X86) || defined (USE_BF)
#include "stdio.h"
#endif

#define TRUSTLET_TAG_I "CRYPTO_CORE TL [INFO]: "
#define TRUSTLET_TAG_E "CRYPTO_CORE TL [ERROR]: "

#if defined(TL_DEBUG)
    #ifdef QSEE
        #define CC_LOGI(...) qsee_log(QSEE_LOG_MSG_DEBUG, CRYPTO_CORE [INFO]:  ## __VA_ARGS__)
        #define CC_LOGE(...) qsee_log(QSEE_LOG_MSG_ERROR, CRYPTO_CORE [ERROR]: ## __VA_ARGS__)
    #endif /* QSEE */
    #if defined (MOBICORE) || defined (MOBICORE_TL)
        #define CC_LOGI(...) tlDbgPrintf(TRUSTLET_TAG_I ## __VA_ARGS__); tlDbgPrintf("\n")
        #define CC_LOGE(...) tlDbgPrintf(TRUSTLET_TAG_E ## __VA_ARGS__); tlDbgPrintf("\n")
    #endif /* MOBICORE */

    #if defined (X86) || defined (USE_BF)
        #define CC_LOGI(...) printf(TRUSTLET_TAG_I); printf( __VA_ARGS__ ); printf("\n")
        #define CC_LOGE(...) printf(TRUSTLET_TAG_E); printf( __VA_ARGS__ ); printf("\n")
    #endif /* x86 */
#else
    #define CC_LOGI(...)
    #ifdef QSEE
        #define CC_LOGE(...) qsee_log(QSEE_LOG_MSG_ERROR, __VA_ARGS__)
    #endif /* QSEE */
    #if defined (MOBICORE) || defined (MOBICORE_TL)
        #define CC_LOGE(...) tlDbgPrintf(TRUSTLET_TAG_E ## __VA_ARGS__); tlDbgPrintf("\n")
    #endif /* MOBICORE */

    #if defined (X86) || defined (USE_BF) || defined (USE_VS)
        #define CC_LOGE(...) printf(TRUSTLET_TAG_E); printf( __VA_ARGS__ ); printf("\n")
    #endif /* x86 */

#endif

#endif /* CC_LOG_H */
