Merge branch 'feature/InternalLogger' into develop
This commit is contained in:
commit
3de49545b7
@ -94,7 +94,7 @@ dependencies {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'com.orhanobut:logger:2.2.0'
|
||||
implementation 'com.github.lupaulus:logger:2.3.2'
|
||||
|
||||
//Firebase
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import java.util.List;
|
||||
import it.integry.barcode_base_android_library.interfaces.BarcodeReaderInterface;
|
||||
import it.integry.barcode_base_android_library.model.BarcodeSetting;
|
||||
import it.integry.honeywellscannerlibrary.HoneyWellBarcodeReader;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
import it.integry.integrywmsnative.gest.settings.MainSettingsFragment;
|
||||
import it.integry.keyobardemulatorscannerlibrary.KeyboardEmulatorBarcodeReader;
|
||||
import it.integry.pointmobilescannerlibrary.PointMobileBarcodeReader;
|
||||
@ -135,10 +136,12 @@ public class BarcodeManager {
|
||||
|
||||
public static void disable() {
|
||||
mEnabled = false;
|
||||
UtilityLogger.trace("Barcode reader disabled");
|
||||
}
|
||||
|
||||
public static void enable() {
|
||||
mEnabled = true;
|
||||
UtilityLogger.trace("Barcode reader enabled");
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
|
||||
@ -4,8 +4,11 @@ import android.content.Context;
|
||||
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
import com.orhanobut.logger.AndroidLogAdapter;
|
||||
import com.orhanobut.logger.DiskLogAdapter;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@ -36,8 +39,6 @@ public class AppContext {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Inject
|
||||
public void init() {
|
||||
this.initUtilities();
|
||||
@ -56,10 +57,10 @@ public class AppContext {
|
||||
}
|
||||
|
||||
private void initCrashlytics() {
|
||||
if(!BuildConfig.DEBUG) {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
|
||||
|
||||
if( SettingsManager.isInstanceAvailable() &&
|
||||
if (SettingsManager.isInstanceAvailable() &&
|
||||
(SettingsManager.i().getUserSession() != null && !UtilityString.isNullOrEmpty(SettingsManager.i().getUserSession().getProfileDB())) &&
|
||||
(SettingsManager.i().getUser() != null && !UtilityString.isNullOrEmpty(SettingsManager.i().getUser().getFullname()))) {
|
||||
|
||||
@ -77,6 +78,11 @@ public class AppContext {
|
||||
|
||||
private void initLogger() {
|
||||
Logger.addLogAdapter(new AndroidLogAdapter());
|
||||
|
||||
File logsFolder = new File(mApplicationContext.getExternalFilesDir(null).getAbsolutePath());
|
||||
int maxBytesSize = 5000;
|
||||
Logger.addLogAdapter(new DiskLogAdapter(logsFolder, maxBytesSize));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ public class ExceptionsHandler implements Thread.UncaughtExceptionHandler {
|
||||
@Override
|
||||
public void uncaughtException(final Thread thread, final Throwable ex) {
|
||||
try {
|
||||
UtilityLogger.errorMe(new Exception(ex));
|
||||
UtilityLogger.error(new Exception(ex));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Exception Logger failed!", e);
|
||||
MainApplication.exit();
|
||||
|
||||
@ -175,7 +175,7 @@ public class MtbColt extends EntityBase {
|
||||
try {
|
||||
dataColloD = getDataColloD();
|
||||
} catch (Exception ex) {
|
||||
UtilityLogger.errorMe(ex);
|
||||
UtilityLogger.error(ex);
|
||||
}
|
||||
|
||||
if (dataColloD != null) {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package it.integry.integrywmsnative.core.model;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
|
||||
public class MtbDepoPosizione {
|
||||
@ -19,7 +18,7 @@ public class MtbDepoPosizione {
|
||||
return (MtbDepoPosizione) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
UtilityLogger.errorMe(e);
|
||||
UtilityLogger.error(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@ -61,7 +61,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<GestSetupDTO>> call, Throwable t) {
|
||||
Log.e("PrintCollo", t.toString());
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
if (onFailed != null) onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
@ -88,7 +88,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Throwable t) {
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
if (onFailed != null) onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
@ -109,7 +109,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<PickingObjectDTO>>> call, Throwable t) {
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
@ -174,7 +174,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Throwable t) {
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
@ -79,7 +79,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<GrigliaDTO>> call, Throwable t) {
|
||||
Log.e("getArticoliListino_pv", t.toString());
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
@ -130,7 +130,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
|
||||
@Override
|
||||
public void onFailure(Call<List<ServiceRESTResponse<DtbOrdt>>> call, Throwable t) {
|
||||
Log.e("saveOrdineTerminale_pv", t.toString());
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
@ -51,7 +51,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, Throwable t) {
|
||||
Log.e("GetAvailablePrinters", t.toString());
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
@ -115,7 +115,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, final Throwable t) {
|
||||
Log.e("ProfilesAvailable", t.toString());
|
||||
onFailed.run(new Exception(t));
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ public class UtilityBarcode {
|
||||
private static String getEAN13CheckDigit(String ean) {
|
||||
|
||||
if (ean.length() != 12) {
|
||||
UtilityLogger.errorMe(new Exception("Please provide an input string of 12 chars. Current lenght: " + ean.length()));
|
||||
UtilityLogger.error(new Exception("Please provide an input string of 12 chars. Current lenght: " + ean.length()));
|
||||
return null;
|
||||
}
|
||||
long tot = 0;
|
||||
|
||||
@ -37,7 +37,7 @@ public class UtilityDate {
|
||||
try{
|
||||
return UtilityDate.recognizeDate(dateString);
|
||||
} catch (ParseException | DateNotRecognizedException | TimeNotRecognizedException pex){
|
||||
UtilityLogger.errorMe(pex);
|
||||
UtilityLogger.error(pex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class UtilityExceptions {
|
||||
Stream.of(FIREBASE_IGNORED_EXCEPTIONS).anyMatch(x -> x.isAssignableFrom(ex.getClass()));
|
||||
|
||||
if (!BuildConfig.DEBUG && !toIgnore) {
|
||||
if (sendEmail) UtilityLogger.errorMe(ex);
|
||||
if (sendEmail) UtilityLogger.error(ex);
|
||||
FirebaseCrashlytics.getInstance().recordException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,48 +3,30 @@ package it.integry.integrywmsnative.core.utility;
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.net.SocketException;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import it.integry.integrywmsnative.BuildConfig;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
|
||||
public class UtilityLogger {
|
||||
|
||||
public static void logMe(String message) {
|
||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
public static void trace(String message) {
|
||||
Logger.d(message, getPreviousStackTraceElement());
|
||||
}
|
||||
|
||||
String caller = "UtilityLogger";
|
||||
|
||||
for (int i = 0; i < stackTraceElements.length; i++) {
|
||||
|
||||
if (stackTraceElements[i].getMethodName().equalsIgnoreCase("logMe")) {
|
||||
caller = stackTraceElements[i + 1].getFileName() + "->" + stackTraceElements[i + 1].getMethodName();
|
||||
}
|
||||
|
||||
}
|
||||
public static void info(String message) {
|
||||
Logger.i(message);
|
||||
}
|
||||
|
||||
public static void debug(String message) {
|
||||
Logger.d(message);
|
||||
}
|
||||
|
||||
public static void errorMe(Exception ex) {
|
||||
errorMe(ex, null, null, null);
|
||||
public static void error(Exception ex) {
|
||||
error(ex, "");
|
||||
}
|
||||
|
||||
public static void errorMe(Exception ex, String additionalText) {
|
||||
errorMe(ex, additionalText, null, null);
|
||||
}
|
||||
public static void error(Exception ex, String additionalText) {
|
||||
if (!BuildConfig.DEBUG) FirebaseCrashlytics.getInstance().recordException(ex);
|
||||
|
||||
public static void errorMe(Exception ex, String additionalText, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
if(!BuildConfig.DEBUG) FirebaseCrashlytics.getInstance().recordException(ex);
|
||||
|
||||
logMe(ex.getMessage());
|
||||
Logger.e(ex, additionalText);
|
||||
|
||||
// if ((!(ex instanceof SocketTimeoutException) && !(ex.getCause() instanceof SocketTimeoutException)) ||
|
||||
// (!(ex instanceof SocketException) && !(ex.getCause() instanceof SocketException)) ||
|
||||
@ -82,4 +64,52 @@ public class UtilityLogger {
|
||||
// }
|
||||
}
|
||||
|
||||
private static String getPreviousStackTraceElement() {
|
||||
StackTraceElement[] stackTraceElementsArr = Thread.currentThread().getStackTrace();
|
||||
String caller = "UtilityLogger";
|
||||
StringBuilder callerNew = new StringBuilder();
|
||||
|
||||
int found = 0;
|
||||
|
||||
for (int i = 0; i < stackTraceElementsArr.length; i++) {
|
||||
|
||||
if(!stackTraceElementsArr[i].getClassName().startsWith("it.integry"))
|
||||
continue;
|
||||
|
||||
if (stackTraceElementsArr[i].getMethodName().equalsIgnoreCase("getPreviousStackTraceElement")) {
|
||||
found = i;
|
||||
}
|
||||
|
||||
if (found > 0 && i >= found + 2) {
|
||||
callerNew
|
||||
.append(stackTraceElementsArr[i].getClassName())
|
||||
.append("->")
|
||||
.append(stackTraceElementsArr[i].getMethodName())
|
||||
.append(":")
|
||||
.append(stackTraceElementsArr[i].getLineNumber())
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return callerNew.length() > 0 ? callerNew.toString() : caller;
|
||||
}
|
||||
|
||||
|
||||
// public static void logMe(String message) {
|
||||
// StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
//
|
||||
// String caller = "UtilityLogger";
|
||||
//
|
||||
// for (int i = 0; i < stackTraceElements.length; i++) {
|
||||
//
|
||||
// if (stackTraceElements[i].getMethodName().equalsIgnoreCase("logMe")) {
|
||||
// caller = stackTraceElements[i + 1].getFileName() + "->" + stackTraceElements[i + 1].getMethodName();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// Logger.d(message);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class OrdiniAccettazioneRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Throwable t) {
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
@ -43,7 +43,7 @@ public class AccettazionePickingRESTConsumer {
|
||||
|
||||
whereCondListMap.add(whereCondMap);
|
||||
} catch (Exception ex) {
|
||||
UtilityLogger.errorMe(ex);
|
||||
UtilityLogger.error(ex);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ public class ProdOrdineProduzioneRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Throwable t) {
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
@ -77,7 +77,6 @@ public class RettificaGiacenzeViewModel {
|
||||
this.mDefaultCausale = defaultCausale;
|
||||
this.mCurrentCodMdep = currentCodMdep;
|
||||
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
this.mRettificaGiacenzeRESTConsumer.loadListaFornitori(fornitori -> {
|
||||
|
||||
@ -64,7 +64,7 @@ public abstract class BottomSheetFragmentBaseView extends ConstraintLayout {
|
||||
|
||||
public void expand() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
UtilityLogger.error(new BottomSheetFragmentViewNotInitializedException());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public abstract class BottomSheetFragmentBaseView extends ConstraintLayout {
|
||||
|
||||
public void collapse() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
UtilityLogger.error(new BottomSheetFragmentViewNotInitializedException());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public abstract class BottomSheetFragmentBaseView extends ConstraintLayout {
|
||||
|
||||
public State getState() {
|
||||
if(this.mBottomSheetBehavior == null) {
|
||||
UtilityLogger.errorMe(new BottomSheetFragmentViewNotInitializedException());
|
||||
UtilityLogger.error(new BottomSheetFragmentViewNotInitializedException());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ public class BottomSheetMtbColrEditView extends BottomSheetFragmentBaseView {
|
||||
@Override
|
||||
public void expand() {
|
||||
if(this.mViewModel.getMtbColr() == null) {
|
||||
UtilityLogger.errorMe(new NullMtbColrException());
|
||||
UtilityLogger.error(new NullMtbColrException());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user