1 // Copyright 2021 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package com.google.android.downloader; 16 17 import com.google.common.flogger.GoogleLogger; 18 import com.google.errorprone.annotations.FormatMethod; 19 import com.google.errorprone.annotations.FormatString; 20 import javax.annotation.Nullable; 21 22 /** 23 * Implementation of {@link DownloaderLogger} backed by {@link GoogleLogger}. Google-internal code 24 * should always use this logger. 25 */ 26 public class FloggerDownloaderLogger implements DownloaderLogger { 27 private static final GoogleLogger logger = GoogleLogger.forEnclosingClass(); 28 29 @Override 30 @FormatMethod logFine(@ormatString String message, Object... args)31 public void logFine(@FormatString String message, Object... args) { 32 logger.atFine().logVarargs(message, args); 33 } 34 35 @Override 36 @FormatMethod logInfo(@ormatString String message, Object... args)37 public void logInfo(@FormatString String message, Object... args) { 38 logger.atInfo().logVarargs(message, args); 39 } 40 41 @Override 42 @FormatMethod logWarning(@ormatString String message, Object... args)43 public void logWarning(@FormatString String message, Object... args) { 44 logger.atWarning().logVarargs(message, args); 45 } 46 47 @Override 48 @FormatMethod logWarning(@ullable Throwable cause, @FormatString String message, Object... args)49 public void logWarning(@Nullable Throwable cause, @FormatString String message, Object... args) { 50 logger.atWarning().withCause(cause).logVarargs(message, args); 51 } 52 53 @Override 54 @FormatMethod logError(@ormatString String message, Object... args)55 public void logError(@FormatString String message, Object... args) { 56 logger.atSevere().logVarargs(message, args); 57 } 58 59 @Override 60 @FormatMethod logError(@ullable Throwable cause, @FormatString String message, Object... args)61 public void logError(@Nullable Throwable cause, @FormatString String message, Object... args) { 62 logger.atSevere().withCause(cause).logVarargs(message, args); 63 } 64 } 65