[DEV] use doxygen doc generation instead of monk and correct __class__ name
This commit is contained in:
parent
1f4751c3d7
commit
c3ce5a9ebc
15
doxy_elog.py
Normal file
15
doxy_elog.py
Normal file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import doxy.module as module
|
||||
import doxy.debug as debug
|
||||
import doxy.tools as tools
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name)
|
||||
my_module.set_version([0,1,"dev"])
|
||||
my_module.set_title("Elog: Etk log interface")
|
||||
my_module.set_website("http://atria-soft.github.io/" + module_name)
|
||||
my_module.set_website_sources("http://github.com/atria-soft/" + module_name)
|
||||
my_module.set_path(os.path.join(tools.get_current_path(__file__), module_name))
|
||||
|
||||
return my_module
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
@ -11,6 +11,10 @@
|
||||
#include <assert.h>
|
||||
|
||||
namespace elog {
|
||||
/**
|
||||
* @brief Get local id of the library
|
||||
* @return Unique ID of the library
|
||||
*/
|
||||
int32_t getLogId();
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
|
40
elog/log.cpp
40
elog/log.cpp
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
@ -169,22 +169,22 @@ std::vector<std::string> elog::getListInstance() {
|
||||
return out;
|
||||
}
|
||||
|
||||
void elog::logStream(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const std::ostream& _log) {
|
||||
void elog::logStream(int32_t _id, int32_t _level, int32_t _ligne, const char* _funcName, const std::ostream& _log) {
|
||||
std::ostringstream oss;
|
||||
oss << _log.rdbuf();
|
||||
std::string sss =oss.str();
|
||||
elog::logChar(_id, _level, _ligne, _className, _funcName, sss.c_str());
|
||||
elog::logChar(_id, _level, _ligne, _funcName, sss.c_str());
|
||||
}
|
||||
|
||||
void elog::logChar1(int32_t _id, int32_t _level, const char* _log) {
|
||||
elog::logChar(_id, _level, -1, nullptr, nullptr, _log);
|
||||
elog::logChar(_id, _level, -1, nullptr, _log);
|
||||
}
|
||||
|
||||
void elog::logStream1(int32_t _id, int32_t _level, const std::ostream& _log) {
|
||||
std::ostringstream oss;
|
||||
oss << _log.rdbuf();
|
||||
std::string sss =oss.str();
|
||||
elog::logChar(_id, _level, -1, nullptr, nullptr, sss.c_str());
|
||||
elog::logChar(_id, _level, -1, nullptr, sss.c_str());
|
||||
}
|
||||
|
||||
static bool& getColor() {
|
||||
@ -292,7 +292,7 @@ static void getDisplayTime(char* data) {
|
||||
|
||||
#define LENGHT_MAX_LOG (2048)
|
||||
|
||||
void elog::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const char* _log) {
|
||||
void elog::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _funcName, const char* _log) {
|
||||
static std::mutex g_lock;
|
||||
char handle[LENGHT_MAX_LOG] = "";
|
||||
memset(handle, ' ', LENGHT_MAX_LOG);
|
||||
@ -416,37 +416,33 @@ void elog::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _cla
|
||||
int32_t len = strlen(handle);
|
||||
char tmpName[1024];
|
||||
char *tmpPointer = tmpName;
|
||||
#ifndef __TARGET_OS__Android
|
||||
if (_className != nullptr) {
|
||||
snprintf(tmpPointer, 1024, "%s::", _className);
|
||||
tmpPointer = tmpPointer+strlen(tmpPointer);
|
||||
}
|
||||
#endif
|
||||
if (_funcName != nullptr) {
|
||||
#if defined(__TARGET_OS__Android)
|
||||
// cleen for android :
|
||||
char* startPos = strchr(_funcName, ' ');
|
||||
char* stopPos = strchr(_funcName, '(');
|
||||
char* startPos = strchr((char*)_funcName, ' ');
|
||||
char* stopPos = strchr((char*)_funcName, '(');
|
||||
if (startPos != nullptr) {
|
||||
if (stopPos != nullptr) {
|
||||
if(stopPos < startPos) {
|
||||
snprintf(tmpPointer, std::min(1024, int32_t(stopPos-_funcName)), "%s", _funcName);
|
||||
char* startPos2 = strchr(startPos+1, ' ');
|
||||
while ( startPos2 != nullptr
|
||||
&& startPos2 < stopPos) {
|
||||
startPos = startPos2;
|
||||
startPos2 = strchr(startPos+1, ' ');
|
||||
}
|
||||
if(uint64_t(stopPos) < uint64_t(startPos)) {
|
||||
snprintf(tmpPointer, std::min(uint64_t(1024), uint64_t(stopPos)-uint64_t(_funcName)), "%s", _funcName);
|
||||
} else {
|
||||
snprintf(tmpPointer, std::min(1024, int32_t(stopPos-startPos)), "%s", startPos+1);
|
||||
snprintf(tmpPointer, std::min(uint64_t(1024), uint64_t(stopPos)-uint64_t(startPos)), "%s", startPos+1);
|
||||
}
|
||||
} else {
|
||||
snprintf(tmpPointer, 1024, "%s", startPos);
|
||||
}
|
||||
} else {
|
||||
if (stopPos != nullptr) {
|
||||
snprintf(tmpPointer, std::min(1024, int32_t(stopPos-_funcName)), "%s", _funcName);
|
||||
snprintf(tmpPointer, std::min(uint64_t(1024), uint64_t(stopPos)-uint64_t(_funcName)+1), "%s", _funcName);
|
||||
} else {
|
||||
snprintf(tmpPointer, 1024, "%s", _funcName);
|
||||
}
|
||||
}
|
||||
#else
|
||||
snprintf(tmpPointer, 1024, "%s", _funcName);
|
||||
#endif
|
||||
tmpPointer = tmpPointer+strlen(tmpPointer);
|
||||
}
|
||||
size_t lenFunc = strlen(tmpName);
|
||||
|
46
elog/log.h
46
elog/log.h
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
@ -34,11 +34,14 @@ namespace elog {
|
||||
/**
|
||||
* @brief Set the log level of a specific instance
|
||||
* @param[in] _name Name of the intance
|
||||
* @param[in] _id Id of the intance
|
||||
* @param[in] _level New level to set on the instance
|
||||
*/
|
||||
void setLevel(const std::string& _name, enum level _level);
|
||||
//! @previous
|
||||
/**
|
||||
* @brief Set the log level of a specific instance
|
||||
* @param[in] _id Id of the intance
|
||||
* @param[in] _level New level to set on the instance
|
||||
*/
|
||||
void setLevel(int32_t _id, enum level _level);
|
||||
/**
|
||||
* @brief Set global debug level
|
||||
@ -96,27 +99,40 @@ namespace elog {
|
||||
* @param[in] _id Id of the instance type
|
||||
* @param[in] _level Level debug
|
||||
* @param[in] _ligne Line of the debug
|
||||
* @param[in] _className Class name of the debug
|
||||
* @param[in] _funcName Function name for debug
|
||||
* @param[in] _funcName Function name for debug (compleate decorate signature)
|
||||
* @param[in] _log Stream to log
|
||||
*/
|
||||
void logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _funcName, const char* _log);
|
||||
/**
|
||||
* @brief Call log to display
|
||||
* @param[in] _id Id of the instance type
|
||||
* @param[in] _level Level debug
|
||||
* @param[in] _ligne Line of the debug
|
||||
* @param[in] _funcName Function name for debug (compleate decorate signature)
|
||||
* @param[in] _log Stream to log
|
||||
*/
|
||||
void logStream(int32_t _id, int32_t _level, int32_t _ligne, const char* _funcName, const std::ostream& _log);
|
||||
/**
|
||||
* @brief Call log to display
|
||||
* @param[in] _id Id of the instance type
|
||||
* @param[in] _level Level debug
|
||||
* @param[in] _log Stream to log
|
||||
*/
|
||||
void logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const char* _log);
|
||||
//! @previous
|
||||
void logStream(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const std::ostream& _log);
|
||||
//! @previous
|
||||
void logChar1(int32_t _id, int32_t _level, const char* _log);
|
||||
//! @previous
|
||||
/**
|
||||
* @brief Call log to display
|
||||
* @param[in] _id Id of the instance type
|
||||
* @param[in] _level Level debug
|
||||
* @param[in] _log Stream to log
|
||||
*/
|
||||
void logStream1(int32_t _id, int32_t _level, const std::ostream& _log);
|
||||
/**
|
||||
* @brief Display the current backtrace
|
||||
* @param[in] _breakAtEnd assert program when backtrace is printed
|
||||
* @param[in] _removeElement Number of element remove in the stack before display (permit to remove log function call)
|
||||
*/
|
||||
void displayBacktrace(bool _breakAtEnd = false, int32_t _removeElement=0);
|
||||
};
|
||||
#ifdef __class__
|
||||
#undef __class__
|
||||
#endif
|
||||
#define __class__ (nullptr)
|
||||
|
||||
// generic define for all logs::
|
||||
#define ELOG_BASE(logId,info,data) \
|
||||
@ -125,6 +141,6 @@ namespace elog {
|
||||
std::stringbuf sb; \
|
||||
std::ostream tmpStream(&sb); \
|
||||
tmpStream << data; \
|
||||
elog::logStream(logId, info, __LINE__, __class__, __func__, tmpStream); \
|
||||
elog::logStream(logId, info, __LINE__, __PRETTY_FUNCTION__, tmpStream); \
|
||||
} \
|
||||
} while(0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
|
Loading…
x
Reference in New Issue
Block a user