[DEV] update documentation
This commit is contained in:
parent
5ea8d682b7
commit
a309c2d5aa
17
README.md
17
README.md
@ -1,7 +1,9 @@
|
|||||||
plugin manager
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
6
doc/doc_01_overview.md
Normal file
6
doc/doc_01_overview.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
scenarium-logger Overview
|
||||||
|
=========================
|
||||||
|
|
||||||
|
|
||||||
|
TBD
|
||||||
|
|
97
doc/tutorial_01_create_library_logger.md
Normal file
97
doc/tutorial_01_create_library_logger.md
Normal file
@ -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);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
28
doc/tutorial_02_control_logger.md
Normal file
28
doc/tutorial_02_control_logger.md
Normal file
@ -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.
|
||||||
|
|
||||||
|
|
||||||
|
|
17
menu.json
Normal file
17
menu.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user