[DEV] some clean

This commit is contained in:
Edouard DUPIN 2021-05-03 16:47:02 +02:00
parent 6aa5a0e966
commit d98f2b7769
2 changed files with 49 additions and 33 deletions

View File

@ -49,10 +49,15 @@ public class Ejson {
final ParseJson parser = new ParseJson(builder); final ParseJson parser = new ParseJson(builder);
final ParsingProperty property = new ParsingProperty(); final ParsingProperty property = new ParsingProperty();
property.setDisplayError(true); property.setDisplayError(true);
Log.critical("not implemented..."); final byte[] elemData = Uri.getAllData(data);
return (JsonNode) parser.parse("", property); if (elemData == null) {
Log.error("Can not read the Stream : " + data);
Log.displayBackTrace();
return null;
}
final String dataToParse = new String(elemData);
return (JsonNode) parser.parse(dataToParse, property);
} }
private Ejson() { private Ejson() {}
}
} }

View File

@ -10,61 +10,72 @@ import io.scenarium.logger.Logger;
public class Log { public class Log {
private static final String LIB_NAME = "ejson"; private static final String LIB_NAME = "ejson";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME); private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL); private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR); private static final boolean PRINT_DEBUG = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING); private static final boolean PRINT_ERROR = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO); private static final boolean PRINT_INFO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG); private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE); private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO); private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT); private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING);
public static void critical(final String data) { public static void critical(final String data) {
if (PRINT_CRITICAL) { if (Log.PRINT_CRITICAL) {
Logger.critical(LIB_NAME_DRAW, data); Logger.critical(Log.LIB_NAME_DRAW, data);
}
}
public static void critical(final String data, final Exception e) {
e.printStackTrace();
if (Log.PRINT_CRITICAL) {
Logger.critical(Log.LIB_NAME_DRAW, data + " : " + e.getMessage());
} }
} }
public static void debug(final String data) { public static void debug(final String data) {
if (PRINT_DEBUG) { if (Log.PRINT_DEBUG) {
Logger.debug(LIB_NAME_DRAW, data); Logger.debug(Log.LIB_NAME_DRAW, data);
} }
} }
public static void displayBackTrace() {
Logger.displayBackTrace(Log.LIB_NAME_DRAW);
}
public static void error(final String data) { public static void error(final String data) {
if (PRINT_ERROR) { if (Log.PRINT_ERROR) {
Logger.error(LIB_NAME_DRAW, data); Logger.error(Log.LIB_NAME_DRAW, data);
} }
} }
public static void info(final String data) { public static void info(final String data) {
if (PRINT_INFO) { if (Log.PRINT_INFO) {
Logger.info(LIB_NAME_DRAW, data); Logger.info(Log.LIB_NAME_DRAW, data);
} }
} }
public static void print(final String data) { public static void print(final String data) {
if (PRINT_PRINT) { if (Log.PRINT_PRINT) {
Logger.print(LIB_NAME_DRAW, data); Logger.print(Log.LIB_NAME_DRAW, data);
} }
} }
public static void todo(final String data) { public static void todo(final String data) {
if (PRINT_TODO) { if (Log.PRINT_TODO) {
Logger.todo(LIB_NAME_DRAW, data); Logger.todo(Log.LIB_NAME_DRAW, data);
} }
} }
public static void verbose(final String data) { public static void verbose(final String data) {
if (PRINT_VERBOSE) { if (Log.PRINT_VERBOSE) {
Logger.verbose(LIB_NAME_DRAW, data); Logger.verbose(Log.LIB_NAME_DRAW, data);
} }
} }
public static void warning(final String data) { public static void warning(final String data) {
if (PRINT_WARNING) { if (Log.PRINT_WARNING) {
Logger.warning(LIB_NAME_DRAW, data); Logger.warning(Log.LIB_NAME_DRAW, data);
} }
} }