From c3ce5a9ebc6fa22c438e3c47d1ac920648f1e530 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 30 Mar 2016 22:20:14 +0200 Subject: [PATCH] [DEV] use doxygen doc generation instead of monk and correct __class__ name --- doxy_elog.py | 15 +++++++++++++ elog/debug.cpp | 2 +- elog/debug.h | 6 ++++- elog/elog.cpp | 2 +- elog/elog.h | 2 +- elog/log.cpp | 60 +++++++++++++++++++++++--------------------------- elog/log.h | 46 +++++++++++++++++++++++++------------- elog/logIOs.h | 2 +- elog/logIOs.m | 2 +- 9 files changed, 84 insertions(+), 53 deletions(-) create mode 100644 doxy_elog.py diff --git a/doxy_elog.py b/doxy_elog.py new file mode 100644 index 0000000..691d0c6 --- /dev/null +++ b/doxy_elog.py @@ -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 diff --git a/elog/debug.cpp b/elog/debug.cpp index e600123..5bf93c4 100644 --- a/elog/debug.cpp +++ b/elog/debug.cpp @@ -1,4 +1,4 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved diff --git a/elog/debug.h b/elog/debug.h index 6112f69..ea3e30c 100644 --- a/elog/debug.h +++ b/elog/debug.h @@ -1,4 +1,4 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved @@ -11,6 +11,10 @@ #include namespace elog { + /** + * @brief Get local id of the library + * @return Unique ID of the library + */ int32_t getLogId(); }; diff --git a/elog/elog.cpp b/elog/elog.cpp index c2434cc..f311e08 100644 --- a/elog/elog.cpp +++ b/elog/elog.cpp @@ -1,4 +1,4 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved diff --git a/elog/elog.h b/elog/elog.h index 006b899..5dc098b 100644 --- a/elog/elog.h +++ b/elog/elog.h @@ -1,4 +1,4 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved diff --git a/elog/log.cpp b/elog/log.cpp index 28ab754..dec5234 100644 --- a/elog/log.cpp +++ b/elog/log.cpp @@ -1,4 +1,4 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved @@ -169,22 +169,22 @@ std::vector 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, '('); - if (startPos != nullptr) { - if (stopPos != nullptr) { - if(stopPos < startPos) { - snprintf(tmpPointer, std::min(1024, int32_t(stopPos-_funcName)), "%s", _funcName); - } else { - snprintf(tmpPointer, std::min(1024, int32_t(stopPos-startPos)), "%s", startPos+1); - } + // cleen for android : + char* startPos = strchr((char*)_funcName, ' '); + char* stopPos = strchr((char*)_funcName, '('); + if (startPos != nullptr) { + if (stopPos != nullptr) { + 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, 1024, "%s", startPos); + snprintf(tmpPointer, std::min(uint64_t(1024), uint64_t(stopPos)-uint64_t(startPos)), "%s", startPos+1); } } else { - if (stopPos != nullptr) { - snprintf(tmpPointer, std::min(1024, int32_t(stopPos-_funcName)), "%s", _funcName); - } else { - snprintf(tmpPointer, 1024, "%s", _funcName); - } + snprintf(tmpPointer, 1024, "%s", startPos); } - #else - snprintf(tmpPointer, 1024, "%s", _funcName); - #endif + } else { + if (stopPos != nullptr) { + snprintf(tmpPointer, std::min(uint64_t(1024), uint64_t(stopPos)-uint64_t(_funcName)+1), "%s", _funcName); + } else { + snprintf(tmpPointer, 1024, "%s", _funcName); + } + } tmpPointer = tmpPointer+strlen(tmpPointer); } size_t lenFunc = strlen(tmpName); diff --git a/elog/log.h b/elog/log.h index 95ce2c1..9f755de 100644 --- a/elog/log.h +++ b/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) diff --git a/elog/logIOs.h b/elog/logIOs.h index d5ee377..0772c5c 100644 --- a/elog/logIOs.h +++ b/elog/logIOs.h @@ -1,4 +1,4 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved diff --git a/elog/logIOs.m b/elog/logIOs.m index 51bda87..0d85e3c 100644 --- a/elog/logIOs.m +++ b/elog/logIOs.m @@ -1,4 +1,4 @@ -/** +/** @file * @author Edouard DUPIN * * @copyright 2011, Edouard DUPIN, all right reserved