Skip to content

Commit

Permalink
Merge pull request #13 from AlexDochioiu/14_update_readme
Browse files Browse the repository at this point in the history
#14 Update Readme
  • Loading branch information
AlexDochioiu authored Jul 16, 2018
2 parents 5d23812 + dabeef8 commit 2c9bc3f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ dependencies {
```

## Initializing LazyLogger and Persistence
**In order to use LazyLogger and/or to persist the logs, you must initilize them. This needs doing only once.**
**In order to use LazyLogger and/or to persist the logs, you must initilize them. This needs doing only once using the JeeFoLogger builder. (This is not required unless you want to use persistence, lazylogger or to set the minimum logcat logging level different than VERBOSE)**

```groovy
JeefoLogger.initPersistence(this);
JeefoLogger.initLazyLogger(context);
new JeefoLogger.Builder(context)
.withPersistence(true) // default is false
.withLazyLogger(true) // default is false
.withMinimumLogcatLevel(LogLevel.VERBOSE) // default is LogLevel.VERBOSE
.withMinimumPersistenceLevel(LogLevel.VERBOSE) // default is LogLevel.VERBOSE (this line will not do anything unless withPeristence(true) is used)
.buildAndInit();
```

You must provide an Android `context`. A good place to initialize them is in `onCreate` on an application subclass:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.jeefo.android.jeefologger.ILog;
import com.jeefo.android.jeefologger.JeefoLogger;
import com.jeefo.android.jeefologger.LogLevel;
import com.jeefo.android.jeefologger.SmartLoggerFactory;
import com.jeefo.android.logger.utils.LazyLoggerDemonstrationUtils;
import com.jeefo.android.logger.utils.OnMyExampleEventListener;
Expand Down Expand Up @@ -64,6 +65,8 @@ protected void onCreate(Bundle savedInstanceState) {
new JeefoLogger.Builder(this)
.withPersistence(true)
.withLazyLogger(true)
.withMinimumLogcatLevel(LogLevel.VERBOSE)
.withMinimumPersistenceLevel(LogLevel.VERBOSE)
.buildAndInit();

// To fetch the log files at any point, use the following. This method currently works only after buildAndInit() but this will change in a future version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class FinalLogger implements IInternalLog {
static final String TAG_LOGGING_PREFIX = "[JeeFo-Log]";
@LogLevel
static int persistenceMinLevel = LogLevel.VERBOSE;
static int logcatMinLevel = LogLevel.VERBOSE;

private static final ILog persistentLogger = PersistentLogger.getInstance();

Expand All @@ -40,7 +40,7 @@ private FinalLogger() {
@Override
public void InternalVerbose(@Nullable LinkedList<StackTraceElement> traceElements, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(null, messageToLog, args);
if (persistenceMinLevel <= LogLevel.VERBOSE) {
if (logcatMinLevel <= LogLevel.VERBOSE) {
Log.v(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Verbose(finalMessage);
Expand All @@ -49,7 +49,7 @@ public void InternalVerbose(@Nullable LinkedList<StackTraceElement> traceElement
@Override
public void InternalVerbose(@Nullable LinkedList<StackTraceElement> traceElements, Exception exception, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(exception, messageToLog, args);
if (persistenceMinLevel <= LogLevel.VERBOSE) {
if (logcatMinLevel <= LogLevel.VERBOSE) {
Log.v(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Verbose(finalMessage);
Expand All @@ -58,7 +58,7 @@ public void InternalVerbose(@Nullable LinkedList<StackTraceElement> traceElement
@Override
public void InternalDebug(@Nullable LinkedList<StackTraceElement> traceElements, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(null, messageToLog, args);
if (persistenceMinLevel <= LogLevel.DEBUG) {
if (logcatMinLevel <= LogLevel.DEBUG) {
Log.d(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Debug(finalMessage);
Expand All @@ -67,7 +67,7 @@ public void InternalDebug(@Nullable LinkedList<StackTraceElement> traceElements,
@Override
public void InternalDebug(@Nullable LinkedList<StackTraceElement> traceElements, Exception exception, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(exception, messageToLog, args);
if (persistenceMinLevel <= LogLevel.DEBUG) {
if (logcatMinLevel <= LogLevel.DEBUG) {
Log.d(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Debug(finalMessage);
Expand All @@ -76,7 +76,7 @@ public void InternalDebug(@Nullable LinkedList<StackTraceElement> traceElements,
@Override
public void InternalInfo(@Nullable LinkedList<StackTraceElement> traceElements, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(null, messageToLog, args);
if (persistenceMinLevel <= LogLevel.INFO) {
if (logcatMinLevel <= LogLevel.INFO) {
Log.i(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Info(finalMessage);
Expand All @@ -85,7 +85,7 @@ public void InternalInfo(@Nullable LinkedList<StackTraceElement> traceElements,
@Override
public void InternalWarn(@Nullable LinkedList<StackTraceElement> traceElements, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(null, messageToLog, args);
if (persistenceMinLevel <= LogLevel.WARN) {
if (logcatMinLevel <= LogLevel.WARN) {
Log.w(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Warn(finalMessage);
Expand All @@ -94,7 +94,7 @@ public void InternalWarn(@Nullable LinkedList<StackTraceElement> traceElements,
@Override
public void InternalWarn(@Nullable LinkedList<StackTraceElement> traceElements, Exception exception, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(exception, messageToLog, args);
if (persistenceMinLevel <= LogLevel.WARN) {
if (logcatMinLevel <= LogLevel.WARN) {
Log.w(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Warn(finalMessage);
Expand All @@ -103,7 +103,7 @@ public void InternalWarn(@Nullable LinkedList<StackTraceElement> traceElements,
@Override
public void InternalError(@Nullable LinkedList<StackTraceElement> traceElements, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(null, messageToLog, args);
if (persistenceMinLevel <= LogLevel.ERROR) {
if (logcatMinLevel <= LogLevel.ERROR) {
Log.e(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Error(finalMessage);
Expand All @@ -112,7 +112,7 @@ public void InternalError(@Nullable LinkedList<StackTraceElement> traceElements,
@Override
public void InternalError(@Nullable LinkedList<StackTraceElement> traceElements, Exception exception, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(exception, messageToLog, args);
if (persistenceMinLevel <= LogLevel.ERROR) {
if (logcatMinLevel <= LogLevel.ERROR) {
Log.e(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Error(finalMessage);
Expand All @@ -121,7 +121,7 @@ public void InternalError(@Nullable LinkedList<StackTraceElement> traceElements,
@Override
public void InternalWtf(@Nullable LinkedList<StackTraceElement> traceElements, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(null, messageToLog, args);
if (persistenceMinLevel <= LogLevel.WTF) {
if (logcatMinLevel <= LogLevel.WTF) {
Log.wtf(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Wtf(finalMessage);
Expand All @@ -130,7 +130,7 @@ public void InternalWtf(@Nullable LinkedList<StackTraceElement> traceElements, S
@Override
public void InternalWtf(@Nullable LinkedList<StackTraceElement> traceElements, Exception exception, String messageToLog, Object... args) {
String finalMessage = getFormattedMessage(exception, messageToLog, args);
if (persistenceMinLevel <= LogLevel.WTF) {
if (logcatMinLevel <= LogLevel.WTF) {
Log.wtf(TAG_LOGGING_PREFIX + PersistentTagsManager.getTagsStringPrefix(), finalMessage);
}
persistentLogger.Wtf(finalMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public void buildAndInit() {
final Context context = appContextWeakReference.get();

if (context != null) {
FinalLogger.persistenceMinLevel = minPersistenceLevel;

FinalLogger.logcatMinLevel = minLogcatLevel;

if (useLazyLogger) {
LazyLogger.packageName = context.getPackageName();
Expand Down

0 comments on commit 2c9bc3f

Please sign in to comment.