diff options
Diffstat (limited to 'sdkmanager')
| -rw-r--r-- | sdkmanager/app/tests/com/android/sdkmanager/CommandLineProcessorTest.java | 5 | ||||
| -rw-r--r-- | sdkmanager/app/tests/com/android/sdkmanager/SdkCommandLineTest.java | 5 | ||||
| -rw-r--r-- | sdkmanager/libs/sdklib/src/com/android/sdklib/ISdkLog.java | 31 | ||||
| -rw-r--r-- | sdkmanager/libs/sdklib/src/com/android/sdklib/StdSdkLog.java (renamed from sdkmanager/app/tests/com/android/sdkmanager/MockStdLogger.java) | 13 |
4 files changed, 38 insertions, 16 deletions
diff --git a/sdkmanager/app/tests/com/android/sdkmanager/CommandLineProcessorTest.java b/sdkmanager/app/tests/com/android/sdkmanager/CommandLineProcessorTest.java index a213652..688ce52 100644 --- a/sdkmanager/app/tests/com/android/sdkmanager/CommandLineProcessorTest.java +++ b/sdkmanager/app/tests/com/android/sdkmanager/CommandLineProcessorTest.java @@ -17,13 +17,14 @@ package com.android.sdkmanager; import com.android.sdklib.ISdkLog; +import com.android.sdklib.StdSdkLog; import junit.framework.TestCase; public class CommandLineProcessorTest extends TestCase { - private MockStdLogger mLog; + private StdSdkLog mLog; /** * A mock version of the {@link CommandLineProcessor} class that does not @@ -92,7 +93,7 @@ public class CommandLineProcessorTest extends TestCase { @Override protected void setUp() throws Exception { - mLog = new MockStdLogger(); + mLog = new StdSdkLog(); super.setUp(); } diff --git a/sdkmanager/app/tests/com/android/sdkmanager/SdkCommandLineTest.java b/sdkmanager/app/tests/com/android/sdkmanager/SdkCommandLineTest.java index 07a32e0..8206e2a 100644 --- a/sdkmanager/app/tests/com/android/sdkmanager/SdkCommandLineTest.java +++ b/sdkmanager/app/tests/com/android/sdkmanager/SdkCommandLineTest.java @@ -17,12 +17,13 @@ package com.android.sdkmanager; import com.android.sdklib.ISdkLog; +import com.android.sdklib.StdSdkLog; import junit.framework.TestCase; public class SdkCommandLineTest extends TestCase { - private MockStdLogger mLog; + private StdSdkLog mLog; /** * A mock version of the {@link SdkCommandLine} class that does not @@ -69,7 +70,7 @@ public class SdkCommandLineTest extends TestCase { @Override protected void setUp() throws Exception { - mLog = new MockStdLogger(); + mLog = new StdSdkLog(); super.setUp(); } diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/ISdkLog.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/ISdkLog.java index 163f7a9..ec22177 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/ISdkLog.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/ISdkLog.java @@ -20,9 +20,26 @@ import java.util.Formatter; /** * Interface used to display warnings/errors while parsing the SDK content. + * <p/> + * There are a few default implementations available: + * <ul> + * <li> {@link NullSdkLog} is an implementation that does <em>nothing</em> with the log. + * Useful for limited cases where you need to call a class that requires a non-null logging + * yet the calling code does not have any mean of reporting logs itself. It can be + * acceptable for use a temporary implementation but most of the time that means the caller + * code needs to be reworked to take a logger object from its own caller. + * </li> + * <li> {@link StdSdkLog} is an implementation that dumps the log to {@link System#out} or + * {@link System#err}. This is useful for unit tests or code that does not have any GUI. + * Apps based on Eclipse or SWT should not use it and should provide a better way to report + * to the user. + * </li> + * <li> ADT has a <code>AdtPlugin</code> which implements a similar interface called + * <code>ILogger</code>, useful in case we don't want to pull the whole SdkLib. + * </ul> */ public interface ISdkLog { - + /** * Prints a warning message on stdout. * <p/> @@ -30,13 +47,13 @@ public interface ISdkLog { * need to put such a prefix in the format string. * <p/> * Implementations should only display warnings in verbose mode. - * + * * @param warningFormat is an optional error format. If non-null, it will be printed * using a {@link Formatter} with the provided arguments. * @param args provides the arguments for warningFormat. */ void warning(String warningFormat, Object... args); - + /** * Prints an error message on stderr. * <p/> @@ -44,7 +61,7 @@ public interface ISdkLog { * need to put such a prefix in the format string. * <p/> * Implementation should always display errors, independent of verbose mode. - * + * * @param t is an optional {@link Throwable} or {@link Exception}. If non-null, it's * message will be printed out. * @param errorFormat is an optional error format. If non-null, it will be printed @@ -52,13 +69,13 @@ public interface ISdkLog { * @param args provides the arguments for errorFormat. */ void error(Throwable t, String errorFormat, Object... args); - + /** * Prints a message as-is on stdout. * <p/> - * Implementation should always display errors, independent of verbose mode. + * Implementation can omit printing such messages when not in verbose mode. * No prefix is used, the message is printed as-is after formatting. - * + * * @param msgFormat is an optional error format. If non-null, it will be printed * using a {@link Formatter} with the provided arguments. * @param args provides the arguments for msgFormat. diff --git a/sdkmanager/app/tests/com/android/sdkmanager/MockStdLogger.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/StdSdkLog.java index 961e88d..1683808 100644 --- a/sdkmanager/app/tests/com/android/sdkmanager/MockStdLogger.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/StdSdkLog.java @@ -4,7 +4,7 @@ * Licensed under the Eclipse Public License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.eclipse.org/org/documents/epl-v10.php * * Unless required by applicable law or agreed to in writing, software @@ -14,14 +14,17 @@ * limitations under the License. */ -package com.android.sdkmanager; +package com.android.sdklib; -import com.android.sdklib.ISdkLog; /** - * + * An implementation of {@link ISdkLog} that prints to {@link System#out} and {@link System#err}. + * <p/> + * This is mostly useful for unit tests. It should not be used by GUI-based tools (e.g. + * Eclipse plugin or SWT-based apps) which should have a better way to expose their logging + * error and warnings. */ -public class MockStdLogger implements ISdkLog { +public class StdSdkLog implements ISdkLog { public void error(Throwable t, String errorFormat, Object... args) { if (errorFormat != null) { |
