From a309c2d5aae6f60bd1181994c31786d584c3527b Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 26 Jan 2021 00:25:43 +0100 Subject: [PATCH] [DEV] update documentation --- README.md | 17 ++++- doc/doc_01_overview.md | 6 ++ doc/tutorial_01_create_library_logger.md | 97 ++++++++++++++++++++++++ doc/tutorial_02_control_logger.md | 28 +++++++ menu.json | 17 +++++ 5 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 doc/doc_01_overview.md create mode 100644 doc/tutorial_01_create_library_logger.md create mode 100644 doc/tutorial_02_control_logger.md create mode 100644 menu.json diff --git a/README.md b/README.md index ab5e995..374012a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ plugin manager ============== -[MPL-2] generic plugin interface for complex modular system +[MPL-2] generic log interface for java application + +This module will permit to simply ```wrap``` all the log generated by all modules and permit to us to chaange the backend in a future work or depending on some specific implementation @@ -11,3 +13,16 @@ plugin manager + +Tutorials: +========== + +[global overview](doc/doc_01_overview.md) +[contribution guideline](doc/contribution_guideline.md) + +Practices: + + - 01: [Create your own logger](doc/tutorial_01_create_library_logger.md) + - 02: [Control the logger](doc/tutorial_02_control_logger.md) + + diff --git a/doc/doc_01_overview.md b/doc/doc_01_overview.md new file mode 100644 index 0000000..90fe947 --- /dev/null +++ b/doc/doc_01_overview.md @@ -0,0 +1,6 @@ +scenarium-logger Overview +========================= + + +TBD + diff --git a/doc/tutorial_01_create_library_logger.md b/doc/tutorial_01_create_library_logger.md new file mode 100644 index 0000000..e778550 --- /dev/null +++ b/doc/tutorial_01_create_library_logger.md @@ -0,0 +1,97 @@ +Create your own logger +====================== + +Import the Module +================= + +in the file ```module-info.java``` add the require of the module + + +```{.java} +requires transitive io.scenarium.logger; +``` + +Create your local interface +=========================== + +Create a package (that must not be exported): ```src/xxx/yyy/internal/``` + +Add a Class: ```Log.java``` + +with: + +```{.java} +package xxx.yyy.internal; + +import io.scenarium.logger.LogLevel; +import io.scenarium.logger.Logger; + +public class Log { + private static final String LIB_NAME = "xxx.yyy"; + private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME); + private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL); + private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR); + private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING); + private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO); + private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG); + private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE); + private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO); + private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT); + + private Log() {} + + public static void print(String data) { + if (PRINT_PRINT) + Logger.print(LIB_NAME_DRAW, data); + } + + public static void critical(String data) { + if (PRINT_CRITICAL) + Logger.critical(LIB_NAME_DRAW, data); + } + + public static void error(String data) { + if (PRINT_ERROR) + Logger.error(LIB_NAME_DRAW, data); + } + + public static void warning(String data) { + if (PRINT_WARNING) + Logger.warning(LIB_NAME_DRAW, data); + } + + public static void info(String data) { + if (PRINT_INFO) + Logger.info(LIB_NAME_DRAW, data); + } + + public static void debug(String data) { + if (PRINT_DEBUG) + Logger.debug(LIB_NAME_DRAW, data); + } + + public static void verbose(String data) { + if (PRINT_VERBOSE) + Logger.verbose(LIB_NAME_DRAW, data); + } + + public static void todo(String data) { + if (PRINT_TODO) + Logger.todo(LIB_NAME_DRAW, data); + } +} + +``` + + +Generate some Logs: +=================== + + +```{.java} +final int plop = 51615; +Log.info("ma super ligne de Log " + plop); +Log.error("a beautifull error); +``` + + diff --git a/doc/tutorial_02_control_logger.md b/doc/tutorial_02_control_logger.md new file mode 100644 index 0000000..7b1eb59 --- /dev/null +++ b/doc/tutorial_02_control_logger.md @@ -0,0 +1,28 @@ +Control the log level +===================== + +Change the Level of the Log: +============================ + +With the system property: + + - ```logger.level```: Change the level of the log display: + - critical + - error + - warning + - info + - debug + - verbose; + - ```logger.color```: Change the color of the log (true/false) + + +The second solution depend of the appication capability (check --help) + + +Log in color information +======================== + +If the color is enable thing to change the default console of eclipse, to support the ascii color code. + + + diff --git a/menu.json b/menu.json new file mode 100644 index 0000000..c891b9b --- /dev/null +++ b/menu.json @@ -0,0 +1,17 @@ +{ + "documentation": [ + { + "title": "global overview", + "page": "doc/doc_01_overview.md" + } + ], + "tutorial": [ + { + "title": "Create your own logger", + "page": "doc/tutorial_01_create_library_logger.md" + },{ + "title": "Control the logger", + "page": "doc/tutorial_02_control_logger.md" + } + ] +} \ No newline at end of file