1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.utils; 18 19 import com.android.annotations.NonNull; 20 21 import java.util.Formatter; 22 23 /** 24 * Interface used to display warnings/errors while parsing the SDK content. 25 * <p/> 26 * There are a few default implementations available: 27 * <ul> 28 * <li> {@link NullLogger} is an implementation that does <em>nothing</em> with the log. 29 * Useful for limited cases where you need to call a class that requires a non-null logging 30 * yet the calling code does not have any mean of reporting logs itself. It can be 31 * acceptable for use as a temporary implementation but most of the time that means the caller 32 * code needs to be reworked to take a logger object from its own caller. 33 * </li> 34 * <li> {@link StdLogger} is an implementation that dumps the log to {@link System#out} or 35 * {@link System#err}. This is useful for unit tests or code that does not have any GUI. 36 * GUI based apps based should not use it and should provide a better way to report to the user. 37 * </li> 38 * </ul> 39 */ 40 public interface ILogger { 41 42 /** 43 * Prints an error message. 44 * 45 * @param t is an optional {@link Throwable} or {@link Exception}. If non-null, its 46 * message will be printed out. 47 * @param msgFormat is an optional error format. If non-null, it will be printed 48 * using a {@link Formatter} with the provided arguments. 49 * @param args provides the arguments for errorFormat. 50 */ error(Throwable t, String msgFormat, Object... args)51 void error(Throwable t, String msgFormat, Object... args); 52 53 /** 54 * Prints a warning message. 55 * 56 * @param msgFormat is a string format to be used with a {@link Formatter}. Cannot be null. 57 * @param args provides the arguments for warningFormat. 58 */ warning(@onNull String msgFormat, Object... args)59 void warning(@NonNull String msgFormat, Object... args); 60 61 /** 62 * Prints an information message. 63 * 64 * @param msgFormat is a string format to be used with a {@link Formatter}. Cannot be null. 65 * @param args provides the arguments for msgFormat. 66 */ info(@onNull String msgFormat, Object... args)67 void info(@NonNull String msgFormat, Object... args); 68 69 /** 70 * Prints a verbose message. 71 * 72 * @param msgFormat is a string format to be used with a {@link Formatter}. Cannot be null. 73 * @param args provides the arguments for msgFormat. 74 */ verbose(@onNull String msgFormat, Object... args)75 void verbose(@NonNull String msgFormat, Object... args); 76 77 } 78