[DOC] first doc corect release
This commit is contained in:
parent
c3ce5a9ebc
commit
91cd2e9058
53
doc/mainpage.md
Normal file
53
doc/mainpage.md
Normal file
@ -0,0 +1,53 @@
|
||||
Elog library {#mainpage}
|
||||
============
|
||||
|
||||
What is ELOG?
|
||||
-------------
|
||||
|
||||
ELOG, or [**EWOL**](http://atria-soft.github.io/ewol) Logger, is a simple wrapper to concataine log with a simple basic macro ELOG_BASE().
|
||||
|
||||
Where can I use it?
|
||||
-------------------
|
||||
|
||||
Everywhere! EWOL is cross-platform devolopped to support bases OS:
|
||||
- Linux (X11) (mouse)
|
||||
- Windows (mouse) (build on linux...)
|
||||
- MacOs (mouse)
|
||||
- Android (mouse + touch)
|
||||
- IOs (touch)
|
||||
|
||||
What languages are supported?
|
||||
-----------------------------
|
||||
|
||||
EWOL is written in C++
|
||||
|
||||
Are there any licensing restrictions?
|
||||
-------------------------------------
|
||||
|
||||
EWOL is **FREE software** and //all sub-library are FREE and staticly linkable !!!//
|
||||
|
||||
We have no dependency expected generic lib C++ (STL or CXX)
|
||||
|
||||
License (APACHE 2)
|
||||
------------------
|
||||
|
||||
Copyright elog Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
<http://www.apache.org/licenses/LICENSE-2.0>
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Main documentation:
|
||||
-------------------
|
||||
|
||||
@ref elog_tutorial
|
||||
|
||||
[**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html)
|
9
doc/tutorial.md
Normal file
9
doc/tutorial.md
Normal file
@ -0,0 +1,9 @@
|
||||
Tutorials {#elog_tutorial}
|
||||
=========
|
||||
|
||||
@subpage elog_tutorial_01
|
||||
|
||||
@subpage elog_tutorial_02
|
||||
|
||||
@subpage elog_tutorial_03
|
||||
|
89
doc/tutorial_01_add_log.md
Normal file
89
doc/tutorial_01_add_log.md
Normal file
@ -0,0 +1,89 @@
|
||||
Elog Tutorial: Add some Log (using) {#elog_tutorial_01}
|
||||
===================================
|
||||
|
||||
You might not use the log directly.
|
||||
The reson is simple:
|
||||
- It is designed to be replaced by an other log library.
|
||||
|
||||
This permit you to use custom log library just replacing Macro and basic functions
|
||||
|
||||
|
||||
Declaring the list of macro
|
||||
---------------------------
|
||||
|
||||
|
||||
**debug.h**
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.h>
|
||||
|
||||
namespace appl {
|
||||
int32_t getLogId();
|
||||
};
|
||||
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
|
||||
|
||||
#define APPL_PRINT(data) APPL_BASE(-1, data)
|
||||
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
||||
#define APPL_ERROR(data) APPL_BASE(2, data)
|
||||
#define APPL_WARNING(data) APPL_BASE(3, data)
|
||||
#ifdef DEBUG
|
||||
#define APPL_INFO(data) APPL_BASE(4, data)
|
||||
#define APPL_DEBUG(data) APPL_BASE(5, data)
|
||||
#define APPL_VERBOSE(data) APPL_BASE(6, data)
|
||||
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
|
||||
#else
|
||||
#define APPL_INFO(data) do { } while(false)
|
||||
#define APPL_DEBUG(data) do { } while(false)
|
||||
#define APPL_VERBOSE(data) do { } while(false)
|
||||
#define APPL_TODO(data) do { } while(false)
|
||||
#endif
|
||||
|
||||
#define APPL_ASSERT(cond,data) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
APPL_CRITICAL(data); \
|
||||
assert(!#cond); \
|
||||
} \
|
||||
} while (0)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
**debug.cpp**
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
|
||||
#include "debug.h"
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("your application name");
|
||||
return g_val;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- on your main application:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
|
||||
#include <elog/elog.h>
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
elog::init(_argc, _argv);
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Using it
|
||||
--------
|
||||
|
||||
You just need to call the macro whe you want to add debug log:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
|
||||
APPL_INFO("Hello, how are you?");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Specification of logs
|
||||
---------------------
|
||||
|
||||
- *_CRITICAL(***); This will log the data and asert just after (display backtrace if possible)
|
||||
- *_PRINT(***); display on console (can not be removed with the log-level)
|
||||
|
||||
|
||||
|
52
doc/tutorial_02_runtime_use.md
Normal file
52
doc/tutorial_02_runtime_use.md
Normal file
@ -0,0 +1,52 @@
|
||||
Elog Tutorial: Runtime use {#elog_tutorial_02}
|
||||
==========================
|
||||
|
||||
When you build your application you can access some log configuration:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh}
|
||||
./yourApplication --help
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
you might have an output for elog:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh}
|
||||
[P] elog - help :
|
||||
[P] yourApplication [options]
|
||||
[P] --elog-level= Change the default log level (set all Log level):
|
||||
[P] 0: debug None (default in release)
|
||||
[P] 1: debug Critical
|
||||
[P] 2: debug Error
|
||||
[P] 3: debug Warning
|
||||
[P] 4: debug Info (default in debug)
|
||||
[P] 5: debug Debug
|
||||
[P] 6: debug Verbose
|
||||
[P] --elog-lib=name:X Set a library specific level:
|
||||
[P] name Name of the library
|
||||
[P] X Log level to set [0..6]
|
||||
[P] --elog-color Enable color in log (default in Linux/debug)
|
||||
[P] --elog-no-color Disable color in log (default in Linux/release and Other)
|
||||
[P] --elog-config= Configure the Log interface
|
||||
[P] t: diplay time
|
||||
[P] T: diplay thread id
|
||||
[P] N: diplay thread name
|
||||
[P] L: diplay line number
|
||||
[P] l: diplay lib name
|
||||
[P] f: diplay function name
|
||||
[P] -h/--help: this help
|
||||
[P] example:
|
||||
[P] yourApplication --elog-color --elog-level=2 --elog-lib=etk:5 --elog-lib=appl:6 --elog-config=NLlf
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Then you can simply select the log level with:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh}
|
||||
./yourApplication --elog-level=5
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Or select a sub-element log level:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh}
|
||||
./yourApplication --elog-lib=elog:1 --elog-lib=appl:6
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
8
doc/tutorial_03_optionnal_dependency.md
Normal file
8
doc/tutorial_03_optionnal_dependency.md
Normal file
@ -0,0 +1,8 @@
|
||||
Elog Tutorial: Optionnal dependency {#elog_tutorial_03}
|
||||
===================================
|
||||
|
||||
Elog have 1 optionnal dependency that is [ethread](http://atria-soft.github.io/ethread)
|
||||
|
||||
It permit to register a name of a thread and a specific unique ID.
|
||||
|
||||
|
@ -10,6 +10,9 @@ def create(target, module_name):
|
||||
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))
|
||||
my_module.set_path([
|
||||
os.path.join(tools.get_current_path(__file__), module_name),
|
||||
os.path.join(tools.get_current_path(__file__), "doc"),
|
||||
])
|
||||
|
||||
return my_module
|
||||
|
@ -18,7 +18,7 @@ namespace elog {
|
||||
int32_t getLogId();
|
||||
};
|
||||
|
||||
#define ELOG_BASIC(info,data) ELOG_BASE(elog::getLogId(),info,data)
|
||||
#define ELOG_BASIC(info,data) ELOG_BASE(elog::getLogId(),info,data)
|
||||
|
||||
#define ELOG_PRINT(data) ELOG_BASIC(-1, data)
|
||||
#define ELOG_CRITICAL(data) ELOG_BASIC(1, data)
|
||||
|
@ -12,22 +12,22 @@
|
||||
|
||||
static elog::level getLogLevel(const std::string& _value) {
|
||||
if (_value == "0") {
|
||||
return elog::logLevelNone;
|
||||
return elog::level_none;
|
||||
} else if (_value == "1") {
|
||||
return elog::logLevelCritical;
|
||||
return elog::level_critical;
|
||||
} else if (_value == "2") {
|
||||
return elog::logLevelError;
|
||||
return elog::level_error;
|
||||
} else if (_value == "3") {
|
||||
return elog::logLevelWarning;
|
||||
return elog::level_warning;
|
||||
} else if (_value == "4") {
|
||||
return elog::logLevelInfo;
|
||||
return elog::level_info;
|
||||
} else if (_value == "5") {
|
||||
return elog::logLevelDebug;
|
||||
return elog::level_debug;
|
||||
} else if (_value == "6") {
|
||||
return elog::logLevelVerbose;
|
||||
return elog::level_verbose;
|
||||
}
|
||||
ELOG_ERROR("Unknow log level : " << _value);
|
||||
return elog::logLevelVerbose;
|
||||
return elog::level_verbose;
|
||||
}
|
||||
|
||||
static bool startWith(const std::string& _obj, const std::string& _val) {
|
||||
@ -73,7 +73,7 @@ void elog::init(int _argc, const char** _argv) {
|
||||
} else if (startWith(data, "--elog-no-color")) {
|
||||
elog::setColor(false);
|
||||
} else if (startWith(data, "--elog-config=")) {
|
||||
std::string value(data.begin()+17, data.end());
|
||||
std::string value(data.begin()+14, data.end());
|
||||
elog::setTime(false);
|
||||
elog::setLine(false);
|
||||
elog::setFunction(false);
|
||||
@ -109,7 +109,7 @@ void elog::init(int _argc, const char** _argv) {
|
||||
|| data == "--help") {
|
||||
ELOG_PRINT("elog - help : ");
|
||||
ELOG_PRINT(" " << _argv[0] << " [options]");
|
||||
ELOG_PRINT(" --elog-level= Change the default log level (set all Log lovel):");
|
||||
ELOG_PRINT(" --elog-level= Change the default log level (set all Log level):");
|
||||
ELOG_PRINT(" 0: debug None (default in release)");
|
||||
ELOG_PRINT(" 1: debug Critical");
|
||||
ELOG_PRINT(" 2: debug Error");
|
||||
@ -124,11 +124,13 @@ void elog::init(int _argc, const char** _argv) {
|
||||
ELOG_PRINT(" --elog-no-color Disable color in log (default in Linux/release and Other)");
|
||||
ELOG_PRINT(" --elog-config= Configure the Log interface");
|
||||
ELOG_PRINT(" t: diplay time");
|
||||
ELOG_PRINT(" T: diplay thread id");
|
||||
ELOG_PRINT(" N: diplay thread name");
|
||||
#ifdef ELOG_BUILD_ETHREAD
|
||||
ELOG_PRINT(" T: diplay thread id");
|
||||
ELOG_PRINT(" N: diplay thread name");
|
||||
#endif
|
||||
ELOG_PRINT(" L: diplay line number");
|
||||
ELOG_PRINT(" l: diplay lib name");
|
||||
ELOG_PRINT(" f: diplay fundtion name");
|
||||
ELOG_PRINT(" f: diplay function name");
|
||||
ELOG_PRINT(" -h/--help: this help");
|
||||
ELOG_PRINT(" example:");
|
||||
ELOG_PRINT(" " << _argv[0] << " --elog-color --elog-level=2 --elog-lib=etk:5 --elog-lib=appl:6 --elog-config=NLlf");
|
||||
|
@ -8,7 +8,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @brief basic namespace of the elog library. (it might contain all the elog fuctions without macro)
|
||||
*/
|
||||
namespace elog {
|
||||
/**
|
||||
* @brief Initialize elog
|
||||
|
49
elog/log.cpp
49
elog/log.cpp
@ -70,7 +70,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEFAULT_LOG_LEVEL elog::logLevelInfo
|
||||
#define DEFAULT_LOG_LEVEL elog::level_info
|
||||
#define DEFAULT_LOG_COLOR true
|
||||
#define DEFAULT_LOG_LINE true
|
||||
#define DEFAULT_LOG_THREAD_ID true
|
||||
@ -79,7 +79,7 @@
|
||||
#define DEFAULT_LOG_TIME true
|
||||
#define DEFAULT_LOG_LIB_NAME true
|
||||
#else
|
||||
#define DEFAULT_LOG_LEVEL elog::logLevelNone
|
||||
#define DEFAULT_LOG_LEVEL elog::level_none
|
||||
#define DEFAULT_LOG_COLOR false
|
||||
#define DEFAULT_LOG_LINE false
|
||||
#define DEFAULT_LOG_THREAD_ID false
|
||||
@ -303,25 +303,25 @@ void elog::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _fun
|
||||
default:
|
||||
// nothing to do ...
|
||||
break;
|
||||
case logLevelCritical:
|
||||
case elog::level_critical:
|
||||
strcat(pointer, ETK_BASH_COLOR_BOLD_RED);
|
||||
break;
|
||||
case logLevelError:
|
||||
case elog::level_error:
|
||||
strcat(pointer, ETK_BASH_COLOR_RED);
|
||||
break;
|
||||
case logLevelWarning:
|
||||
case elog::level_warning:
|
||||
strcat(pointer, ETK_BASH_COLOR_MAGENTA);
|
||||
break;
|
||||
case logLevelInfo:
|
||||
case elog::level_info:
|
||||
strcat(pointer, ETK_BASH_COLOR_CYAN);
|
||||
break;
|
||||
case logLevelDebug:
|
||||
case elog::level_debug:
|
||||
strcat(pointer, ETK_BASH_COLOR_YELLOW);
|
||||
break;
|
||||
case logLevelVerbose:
|
||||
case elog::level_verbose:
|
||||
strcat(pointer, ETK_BASH_COLOR_WHITE);
|
||||
break;
|
||||
case logLevelPrint:
|
||||
case elog::level_print:
|
||||
strcat(pointer, ETK_BASH_COLOR_WHITE);
|
||||
break;
|
||||
}
|
||||
@ -336,25 +336,25 @@ void elog::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _fun
|
||||
default:
|
||||
strcat(pointer, "[?] ");
|
||||
break;
|
||||
case logLevelPrint:
|
||||
case elog::level_print:
|
||||
strcat(pointer, "[P] ");
|
||||
break;
|
||||
case logLevelCritical:
|
||||
case elog::level_critical:
|
||||
strcat(pointer, "[C] ");
|
||||
break;
|
||||
case logLevelError:
|
||||
case elog::level_error:
|
||||
strcat(pointer, "[E] ");
|
||||
break;
|
||||
case logLevelWarning:
|
||||
case elog::level_warning:
|
||||
strcat(pointer, "[W] ");
|
||||
break;
|
||||
case logLevelInfo:
|
||||
case elog::level_info:
|
||||
strcat(pointer, "[I] ");
|
||||
break;
|
||||
case logLevelDebug:
|
||||
case elog::level_debug:
|
||||
strcat(pointer, "[D] ");
|
||||
break;
|
||||
case logLevelVerbose:
|
||||
case elog::level_verbose:
|
||||
strcat(pointer, "[V] ");
|
||||
break;
|
||||
}
|
||||
@ -477,30 +477,29 @@ void elog::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _fun
|
||||
|
||||
g_lock.lock();
|
||||
#if defined(__TARGET_OS__Android)
|
||||
// TODO : Set package name instead of ewol ...
|
||||
switch(_level) {
|
||||
default:
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "EWOL", "%s", handle);
|
||||
break;
|
||||
case logLevelPrint:
|
||||
case elog::level_print:
|
||||
__android_log_print(ANDROID_LOG_INFO, "EWOL", "%s", handle);
|
||||
break;
|
||||
case logLevelCritical:
|
||||
case elog::level_critical:
|
||||
__android_log_print(ANDROID_LOG_FATAL, "EWOL", "%s", handle);
|
||||
break;
|
||||
case logLevelError:
|
||||
case elog::level_error:
|
||||
__android_log_print(ANDROID_LOG_ERROR, "EWOL", "%s", handle);
|
||||
break;
|
||||
case logLevelWarning:
|
||||
case elog::level_warning:
|
||||
__android_log_print(ANDROID_LOG_WARN, "EWOL", "%s", handle);
|
||||
break;
|
||||
case logLevelInfo:
|
||||
case elog::level_info:
|
||||
__android_log_print(ANDROID_LOG_INFO, "EWOL", "%s", handle);
|
||||
break;
|
||||
case logLevelDebug:
|
||||
case elog::level_debug:
|
||||
__android_log_print(ANDROID_LOG_DEBUG, "EWOL", "%s", handle);
|
||||
break;
|
||||
case logLevelVerbose:
|
||||
case elog::level_verbose:
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "EWOL", "%s", handle);
|
||||
break;
|
||||
}
|
||||
@ -510,7 +509,7 @@ void elog::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _fun
|
||||
std::cout << handle << std::endl;
|
||||
#endif
|
||||
g_lock.unlock();
|
||||
if (_level == logLevelCritical) {
|
||||
if (_level == level_critical) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(700));
|
||||
displayBacktrace(true, 2);
|
||||
}
|
||||
|
29
elog/log.h
29
elog/log.h
@ -16,14 +16,14 @@ namespace elog {
|
||||
* @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 {
|
||||
logLevelPrint = -1, //!< basic print for Help or result (never filtered)
|
||||
logLevelNone = 0, //!< no display requested
|
||||
logLevelCritical = 1, //!< Display only critical logs (note that critical generally assert with a backtrace (when we can))
|
||||
logLevelError = 2, //!< Display Error and critical logs
|
||||
logLevelWarning = 3, //!< Display log critical to warning
|
||||
logLevelInfo = 4, //!< Display log critical to information (removed in release mode)
|
||||
logLevelDebug = 5, //!< Display log critical to debug (removed in release mode)
|
||||
logLevelVerbose = 6 //!< Display all logs (removed in release and debug mode)
|
||||
level_print = -1, //!< basic print for Help or result (never filtered)
|
||||
level_none = 0, //!< no display requested
|
||||
level_critical = 1, //!< Display only critical logs (note that critical generally assert with a backtrace (when we can))
|
||||
level_error = 2, //!< Display Error and critical logs
|
||||
level_warning = 3, //!< Display log critical to warning
|
||||
level_info = 4, //!< Display log critical to information (removed in release mode)
|
||||
level_debug = 5, //!< Display log critical to debug (removed in release mode)
|
||||
level_verbose = 6 //!< Display all logs (removed in release and debug mode)
|
||||
};
|
||||
/**
|
||||
* @brief Register an element in the log system
|
||||
@ -36,18 +36,18 @@ namespace elog {
|
||||
* @param[in] _name Name of the intance
|
||||
* @param[in] _level New level to set on the instance
|
||||
*/
|
||||
void setLevel(const std::string& _name, enum level _level);
|
||||
void setLevel(const std::string& _name, enum elog::level _level);
|
||||
/**
|
||||
* @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);
|
||||
void setLevel(int32_t _id, enum elog::level _level);
|
||||
/**
|
||||
* @brief Set global debug level
|
||||
* @param[in] _level New level to set on the instance
|
||||
*/
|
||||
void setLevel(enum level _level);
|
||||
void setLevel(enum elog::level _level);
|
||||
/**
|
||||
* @brief Get the current level of debug for a specific intance
|
||||
* @param[in] _id Id Of the intance
|
||||
@ -134,7 +134,12 @@ namespace elog {
|
||||
void displayBacktrace(bool _breakAtEnd = false, int32_t _removeElement=0);
|
||||
};
|
||||
|
||||
// generic define for all logs::
|
||||
/**
|
||||
* @brief Basic macro of all logs macros
|
||||
* @param[in] logId Id of the library that log
|
||||
* @param[in] info Log level of this log: elog::level
|
||||
* @param[in] data Stream separaated with "<<" convertible in std::ostream
|
||||
*/
|
||||
#define ELOG_BASE(logId,info,data) \
|
||||
do { \
|
||||
if (info <= elog::getLevel(logId)) { \
|
||||
|
Loading…
x
Reference in New Issue
Block a user