[DEV] Add log print
This commit is contained in:
parent
214edf1213
commit
e9583aa311
@ -19,6 +19,7 @@ namespace etk {
|
|||||||
|
|
||||||
#define ETK_BASE(info,data) TK_LOG_BASE(etk::getLogId(),info,data)
|
#define ETK_BASE(info,data) TK_LOG_BASE(etk::getLogId(),info,data)
|
||||||
|
|
||||||
|
#define TK_PRINT(data) ETK_BASE(-1, data)
|
||||||
#define TK_CRITICAL(data) ETK_BASE(1, data)
|
#define TK_CRITICAL(data) ETK_BASE(1, data)
|
||||||
#define TK_ERROR(data) ETK_BASE(2, data)
|
#define TK_ERROR(data) ETK_BASE(2, data)
|
||||||
#define TK_WARNING(data) ETK_BASE(3, data)
|
#define TK_WARNING(data) ETK_BASE(3, data)
|
||||||
|
50
etk/etk.cpp
50
etk/etk.cpp
@ -81,31 +81,31 @@ void etk::init(int _argc, const char** _argv) {
|
|||||||
} else if ( data == "-h"
|
} else if ( data == "-h"
|
||||||
|| data == "--help") {
|
|| data == "--help") {
|
||||||
etk::log::setLevel(etk::log::logLevelInfo);
|
etk::log::setLevel(etk::log::logLevelInfo);
|
||||||
TK_INFO("etk - help : ");
|
TK_PRINT("etk - help : ");
|
||||||
TK_INFO(" " << _argv[0] << " [options]");
|
TK_PRINT(" " << _argv[0] << " [options]");
|
||||||
TK_INFO(" -l/--etk-log-level= Change the default log level (set all Log lovel):");
|
TK_PRINT(" -l/--etk-log-level= Change the default log level (set all Log lovel):");
|
||||||
TK_INFO(" 0: debug None (default in release)");
|
TK_PRINT(" 0: debug None (default in release)");
|
||||||
TK_INFO(" 1: debug Critical");
|
TK_PRINT(" 1: debug Critical");
|
||||||
TK_INFO(" 2: debug Error");
|
TK_PRINT(" 2: debug Error");
|
||||||
TK_INFO(" 3: debug Warning");
|
TK_PRINT(" 3: debug Warning");
|
||||||
TK_INFO(" 4: debug Info (default in debug)");
|
TK_PRINT(" 4: debug Info (default in debug)");
|
||||||
TK_INFO(" 5: debug Debug");
|
TK_PRINT(" 5: debug Debug");
|
||||||
TK_INFO(" 6: debug Verbose");
|
TK_PRINT(" 6: debug Verbose");
|
||||||
TK_INFO(" --etk-log-lib=name:X Set a library specific level:");
|
TK_PRINT(" --etk-log-lib=name:X Set a library specific level:");
|
||||||
TK_INFO(" name Name of the library");
|
TK_PRINT(" name Name of the library");
|
||||||
TK_INFO(" X Log level to set [0..6]");
|
TK_PRINT(" X Log level to set [0..6]");
|
||||||
TK_INFO(" --etk-log-color Enable color in log (default in Linux/debug)");
|
TK_PRINT(" --etk-log-color Enable color in log (default in Linux/debug)");
|
||||||
TK_INFO(" --etk-log-no-color Disable color in log (default in Linux/release and Other)");
|
TK_PRINT(" --etk-log-no-color Disable color in log (default in Linux/release and Other)");
|
||||||
TK_INFO(" --etk-log-config= Configure the Log interface");
|
TK_PRINT(" --etk-log-config= Configure the Log interface");
|
||||||
TK_INFO(" t: diplay time");
|
TK_PRINT(" t: diplay time");
|
||||||
TK_INFO(" T: diplay thread id");
|
TK_PRINT(" T: diplay thread id");
|
||||||
TK_INFO(" N: diplay thread name");
|
TK_PRINT(" N: diplay thread name");
|
||||||
TK_INFO(" L: diplay line number");
|
TK_PRINT(" L: diplay line number");
|
||||||
TK_INFO(" l: diplay lib name");
|
TK_PRINT(" l: diplay lib name");
|
||||||
TK_INFO(" f: diplay fundtion name");
|
TK_PRINT(" f: diplay fundtion name");
|
||||||
TK_INFO(" -h/--help: this help");
|
TK_PRINT(" -h/--help: this help");
|
||||||
TK_INFO(" example:");
|
TK_PRINT(" example:");
|
||||||
TK_INFO(" " << _argv[0] << " --etk-log-color --etk-log-level=2 --etk-log-lib=etk:5 --etk-log-lib=appl:6 --etk-log-config=NLlf");
|
TK_PRINT(" " << _argv[0] << " --etk-log-color --etk-log-level=2 --etk-log-lib=etk:5 --etk-log-lib=appl:6 --etk-log-config=NLlf");
|
||||||
} else if (etk::start_with(data, "--etk")) {
|
} else if (etk::start_with(data, "--etk")) {
|
||||||
TK_ERROR("Can not parse the argument : '" << data << "'");
|
TK_ERROR("Can not parse the argument : '" << data << "'");
|
||||||
}
|
}
|
||||||
|
12
etk/log.cpp
12
etk/log.cpp
@ -319,6 +319,9 @@ void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char*
|
|||||||
case logLevelVerbose:
|
case logLevelVerbose:
|
||||||
strcat(pointer, ETK_BASH_COLOR_WHITE);
|
strcat(pointer, ETK_BASH_COLOR_WHITE);
|
||||||
break;
|
break;
|
||||||
|
case logLevelPrint:
|
||||||
|
strcat(pointer, ETK_BASH_COLOR_WHITE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
pointer = handle+strlen(handle);
|
pointer = handle+strlen(handle);
|
||||||
}
|
}
|
||||||
@ -333,6 +336,9 @@ void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char*
|
|||||||
default:
|
default:
|
||||||
strcat(pointer, "[?] ");
|
strcat(pointer, "[?] ");
|
||||||
break;
|
break;
|
||||||
|
case logLevelPrint:
|
||||||
|
strcat(pointer, "[P] ");
|
||||||
|
break;
|
||||||
case logLevelCritical:
|
case logLevelCritical:
|
||||||
strcat(pointer, "[C] ");
|
strcat(pointer, "[C] ");
|
||||||
break;
|
break;
|
||||||
@ -452,6 +458,9 @@ void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char*
|
|||||||
default:
|
default:
|
||||||
//ROS_VERBOSE_STREAM(handle);
|
//ROS_VERBOSE_STREAM(handle);
|
||||||
break;
|
break;
|
||||||
|
case logLevelPrint:
|
||||||
|
ROS_INFO_STREAM(handle);
|
||||||
|
break;
|
||||||
case logLevelCritical:
|
case logLevelCritical:
|
||||||
ROS_FATAL_STREAM(handle);
|
ROS_FATAL_STREAM(handle);
|
||||||
break;
|
break;
|
||||||
@ -478,6 +487,9 @@ void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char*
|
|||||||
default:
|
default:
|
||||||
__android_log_print(ANDROID_LOG_VERBOSE, "EWOL", "%s", handle);
|
__android_log_print(ANDROID_LOG_VERBOSE, "EWOL", "%s", handle);
|
||||||
break;
|
break;
|
||||||
|
case logLevelPrint:
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "EWOL", "%s", handle);
|
||||||
|
break;
|
||||||
case logLevelCritical:
|
case logLevelCritical:
|
||||||
__android_log_print(ANDROID_LOG_FATAL, "EWOL", "%s", handle);
|
__android_log_print(ANDROID_LOG_FATAL, "EWOL", "%s", handle);
|
||||||
break;
|
break;
|
||||||
|
@ -20,6 +20,7 @@ namespace etk {
|
|||||||
* @brief Log level is a simple list of all log availlable. This enum is used when setting a log and when user chose the level of log displayed.
|
* @brief Log level is a simple list of all log availlable. This enum is used when setting a log and when user chose the level of log displayed.
|
||||||
*/
|
*/
|
||||||
enum level {
|
enum level {
|
||||||
|
logLevelPrint = -1, //!< basic print for Help or result (never filtered)
|
||||||
logLevelNone = 0, //!< no display requested
|
logLevelNone = 0, //!< no display requested
|
||||||
logLevelCritical = 1, //!< Display only critical logs (note that critical generally assert with a backtrace (when we can))
|
logLevelCritical = 1, //!< Display only critical logs (note that critical generally assert with a backtrace (when we can))
|
||||||
logLevelError = 2, //!< Display Error and critical logs
|
logLevelError = 2, //!< Display Error and critical logs
|
||||||
|
Loading…
Reference in New Issue
Block a user