2011-10-19 14:16:31 +02:00
|
|
|
/**
|
|
|
|
*******************************************************************************
|
2011-11-23 11:37:38 +01:00
|
|
|
* @file etk/Debug.h
|
2011-10-19 14:16:31 +02:00
|
|
|
* @brief Ewol Tool Kit : log implementation
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @date 08/06/2010
|
|
|
|
* @par Project
|
|
|
|
* Ewol TK
|
|
|
|
*
|
|
|
|
* @par Copyright
|
|
|
|
* Copyright 2011 Edouard DUPIN, all right reserved
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY.
|
|
|
|
*
|
|
|
|
* Licence summary :
|
|
|
|
* You can modify and redistribute the sources code and binaries.
|
|
|
|
* You can send me the bug-fix
|
|
|
|
*
|
|
|
|
* Term of the licence in in the file licence.txt.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2011-11-23 11:37:38 +01:00
|
|
|
#include <etk/Debug.h>
|
2011-10-19 14:16:31 +02:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
// Max string size : (wide screan console nb caractere)
|
|
|
|
#define EDN_LOG_MAX_LENGTH 250
|
|
|
|
|
|
|
|
|
2011-10-30 18:29:09 +01:00
|
|
|
#define FUNCTION_NAME_SIZE (70)
|
2011-10-19 14:16:31 +02:00
|
|
|
|
|
|
|
void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName)
|
|
|
|
{
|
|
|
|
char tmpName[FUNCTION_NAME_SIZE] = "";
|
|
|
|
|
|
|
|
if (NULL == className) {
|
|
|
|
if (NULL == libName) {
|
2012-04-18 18:14:13 +02:00
|
|
|
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "???????? | (l=%5d) %s ",ligne, funcName);
|
2011-10-19 14:16:31 +02:00
|
|
|
} else {
|
2012-04-18 18:14:13 +02:00
|
|
|
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s ",libName, ligne, funcName);
|
2011-10-19 14:16:31 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (NULL == libName) {
|
2012-04-18 18:14:13 +02:00
|
|
|
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "???????? | (l=%5d) %s::%s ",ligne, className, funcName);
|
2011-10-19 14:16:31 +02:00
|
|
|
} else {
|
2012-04-18 18:14:13 +02:00
|
|
|
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s::%s ", libName, ligne, className, funcName);
|
2011-10-19 14:16:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
tmpName[FUNCTION_NAME_SIZE-4] = ' ';
|
|
|
|
tmpName[FUNCTION_NAME_SIZE-3] = '|';
|
|
|
|
tmpName[FUNCTION_NAME_SIZE-2] = ' ';
|
|
|
|
tmpName[FUNCTION_NAME_SIZE-1] = '\0';
|
2011-12-02 17:23:45 +01:00
|
|
|
etk::cout << tmpName;
|
2011-10-19 14:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TOOLS_DisplayTime(void)
|
|
|
|
{
|
2011-12-30 14:16:57 +01:00
|
|
|
char tmpdata[50];
|
2012-08-10 12:18:24 +02:00
|
|
|
#ifdef __TARGET_OS__Android
|
2011-12-30 14:16:57 +01:00
|
|
|
struct timeval now;
|
|
|
|
gettimeofday(&now, NULL);
|
2012-01-25 23:30:59 +01:00
|
|
|
sprintf(tmpdata, " %2dh %2dmin %2ds | ", (int32_t)(now.tv_sec/3600)%24, (int32_t)(now.tv_sec/60)%60, (int32_t)(now.tv_sec%60));
|
2011-12-30 14:16:57 +01:00
|
|
|
#else
|
2011-10-19 14:16:31 +02:00
|
|
|
time_t rawtime;
|
|
|
|
struct tm * timeinfo;
|
2011-10-27 13:38:55 +02:00
|
|
|
time(&rawtime);
|
|
|
|
timeinfo = localtime(&rawtime);
|
2012-01-25 23:30:59 +01:00
|
|
|
sprintf(tmpdata, " %2dh %2dmin %2ds | ", (timeinfo->tm_hour)%24, timeinfo->tm_min, timeinfo->tm_sec);
|
2011-12-30 14:16:57 +01:00
|
|
|
#endif
|
2011-12-02 17:23:45 +01:00
|
|
|
etk::cout << tmpdata ;
|
2011-10-19 14:16:31 +02:00
|
|
|
}
|
|
|
|
|
2012-06-01 17:47:43 +02:00
|
|
|
|
2012-08-10 12:18:24 +02:00
|
|
|
#ifdef __TARGET_OS__Android
|
2012-06-29 17:56:15 +02:00
|
|
|
etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_VERBOSE;
|
2012-07-02 17:41:51 +02:00
|
|
|
#else
|
|
|
|
etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_ERROR;
|
|
|
|
#endif
|
2012-06-01 17:47:43 +02:00
|
|
|
void GeneralDebugSetLevel(etk::logLevel_te ccc) {
|
2012-07-02 17:41:51 +02:00
|
|
|
g_requestedLevel = ccc;
|
2012-08-15 20:56:16 +02:00
|
|
|
}
|
|
|
|
|