in sdk/core/azure-core-logging/src/main/java/com/azure/android/core/logging/ClientLogger.java [239:288]
private void performLogging(LogLevel logLevel, boolean isExceptionLogging, String format, Object... args) {
// If the logging level is less granular than verbose remove the potential throwable from the args.
String throwableMessage = "";
if (doesArgsHaveThrowable(args)) {
// If we are logging an exception the format string is already the exception message, don't append it.
if (!isExceptionLogging) {
Object throwable = args[args.length - 1];
// This is true from before but is needed to appease SpotBugs.
if (throwable instanceof Throwable) {
throwableMessage = ((Throwable) throwable).getMessage();
}
}
/*
* Environment is logging at a level higher than verbose, strip out the throwable as it would log its
* stack trace which is only expected when logging at a verbose level.
*/
if (!logger.isDebugEnabled()) {
args = removeThrowable(args);
}
}
format = removeNewLinesFromLogMessage(format);
switch (logLevel) {
case VERBOSE:
logger.debug(format, args);
break;
case INFORMATIONAL:
logger.info(format, args);
break;
case WARNING:
if (throwableMessage != null && throwableMessage.length() != 0) {
format += LINE_SEPARATOR + throwableMessage;
}
logger.warn(format, args);
break;
case ERROR:
if (throwableMessage != null && throwableMessage.length() != 0) {
format += LINE_SEPARATOR + throwableMessage;
}
logger.error(format, args);
break;
default:
// Don't do anything, this state shouldn't be possible.
break;
}
}