• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
error(Throwable t, String errorFormat, Object... args)29     public void error(Throwable t, String errorFormat, Object... args) {
30         if (t != null) {
31             AdtPlugin.logAndPrintError(t, TAG, "Error: " + errorFormat, args);
32         } else {
33             AdtPlugin.printErrorToConsole(TAG, String.format(errorFormat, args));
34         }
35     }
36 
printf(String msgFormat, Object... args)37     public void printf(String msgFormat, Object... args) {
38         String msg = String.format(msgFormat, args);
39         for (String s : msg.split("\n")) {
40             if (s.trim().length() > 0) {
41                 AdtPlugin.printToConsole(TAG, s);
42             }
43         }
44     }
45 
warning(String warningFormat, Object... args)46     public void warning(String warningFormat, Object... args) {
47         AdtPlugin.printToConsole(TAG, String.format("Warning: " + warningFormat, args));
48     }
49 }
50