1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php 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.ide.eclipse.adt.internal.sdk; 18 19 import com.android.ide.eclipse.adt.AdtPlugin; 20 import com.android.sdklib.ISdkLog; 21 22 /** 23 * An {@link ISdkLog} logger that outputs to the ADT console. 24 */ 25 public class AdtConsoleSdkLog implements ISdkLog { 26 27 private static final String TAG = "SDK Manager"; //$NON-NLS-1$ 28 29 @Override 30 public void error(Throwable t, String errorFormat, Object... args) { 31 if (t != null) { 32 AdtPlugin.logAndPrintError(t, TAG, "Error: " + errorFormat, args); 33 } else { 34 AdtPlugin.printErrorToConsole(TAG, String.format(errorFormat, args)); 35 } 36 } 37 38 @Override 39 public void printf(String msgFormat, Object... args) { 40 String msg = String.format(msgFormat, args); 41 for (String s : msg.split("\n")) { 42 if (s.trim().length() > 0) { 43 AdtPlugin.printToConsole(TAG, s); 44 } 45 } 46 } 47 48 @Override 49 public void warning(String warningFormat, Object... args) { 50 AdtPlugin.printToConsole(TAG, String.format("Warning: " + warningFormat, args)); 51 } 52 } 53