Prefix DEFAULT_LOG_TAG even when a tag is passed while logging

This commit is contained in:
agnostic-apollo 2021-03-16 03:44:45 +05:00
parent 66f15d2a08
commit 3b5d3114a6
1 changed files with 14 additions and 7 deletions

View File

@ -30,15 +30,15 @@ public class Logger {
static public void logMesssage(int logLevel, String tag, String message) {
if(logLevel == Log.ERROR && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
Log.e(tag, message);
Log.e(getFullTag(tag), message);
else if(logLevel == Log.WARN && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
Log.w(tag, message);
Log.w(getFullTag(tag), message);
else if(logLevel == Log.INFO && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
Log.i(tag, message);
Log.i(getFullTag(tag), message);
else if(logLevel == Log.DEBUG && CURRENT_LOG_LEVEL >= LOG_LEVEL_DEBUG)
Log.d(tag, message);
Log.d(getFullTag(tag), message);
else if(logLevel == Log.VERBOSE && CURRENT_LOG_LEVEL >= LOG_LEVEL_VERBOSE)
Log.v(tag, message);
Log.v(getFullTag(tag), message);
}
@ -133,9 +133,9 @@ public class Logger {
e.printStackTrace(pw);
pw.close();
if(message != null)
Log.e(tag, message + ":\n" + errors.toString());
Log.e(getFullTag(tag), message + ":\n" + errors.toString());
else
Log.e(tag, errors.toString());
Log.e(getFullTag(tag), errors.toString());
errors.close();
} catch (IOException e1) {
e1.printStackTrace();
@ -220,4 +220,11 @@ public class Logger {
return CURRENT_LOG_LEVEL;
}
static public String getFullTag(String tag) {
if(DEFAULT_LOG_TAG.equals(tag))
return tag;
else
return DEFAULT_LOG_TAG + ":" + tag;
}
}