/** * Logs the given message and throwable if the configured filter accepts them. * Each dollar sign in the message is replaced with the corresponding argument. */ @Impure public static void log(@Nonnull Level level, @Nonnull CharSequence message, @Nullable Throwable throwable, @NonCaptured @Unmodified @Nonnull @NullableElements Object... arguments) { final @Nonnull LoggingFilter filter = LoggingFilter.filter.get(); if (filter.isPotentiallyLogged(level)) { final @Nonnull String caller = Caller.get(); final @Nonnull String thread = Thread.currentThread().getName(); final @Nonnull String originalMessage = message.toString(); final boolean addNoPeriod = originalMessage.endsWith(".") || originalMessage.endsWith(":") || originalMessage.endsWith("\n"); final @Nonnull String formattedMessage = Strings.format(originalMessage, arguments) + (addNoPeriod ? "" : "."); if (filter.isLogged(level, caller, thread, formattedMessage, throwable)) { logger.get().log(level, caller, thread, formattedMessage, throwable); } } }