• 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.annotations.NonNull;
20 import com.android.annotations.Nullable;
21 import com.android.ide.eclipse.adt.AdtPlugin;
22 import com.android.utils.ILogger;
23 
24 /**
25  * An {@link ILogger} logger that outputs to the ADT console.
26  */
27 public class AdtConsoleSdkLog implements ILogger {
28 
29     private static final String TAG = "SDK Manager"; //$NON-NLS-1$
30 
31     @Override
error(@ullable Throwable t, @Nullable String errorFormat, Object... args)32     public void error(@Nullable Throwable t, @Nullable String errorFormat, Object... args) {
33         if (t != null) {
34             AdtPlugin.logAndPrintError(t, TAG, "Error: " + errorFormat, args);
35         } else {
36             AdtPlugin.printErrorToConsole(TAG, String.format(errorFormat, args));
37         }
38     }
39 
40     @Override
info(@onNull String msgFormat, Object... args)41     public void info(@NonNull String msgFormat, Object... args) {
42         String msg = String.format(msgFormat, args);
43         for (String s : msg.split("\n")) {
44             if (s.trim().length() > 0) {
45                 AdtPlugin.printToConsole(TAG, s);
46             }
47         }
48     }
49 
50     @Override
verbose(@onNull String msgFormat, Object... args)51     public void verbose(@NonNull String msgFormat, Object... args) {
52         info(msgFormat, args);
53     }
54 
55     @Override
warning(@onNull String warningFormat, Object... args)56     public void warning(@NonNull String warningFormat, Object... args) {
57         AdtPlugin.printToConsole(TAG, String.format("Warning: " + warningFormat, args));
58     }
59 }
60