LogPrinter.java revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
1/* 2 * Copyright (C) 2006 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 17package android.util; 18 19/** 20 * Implementation of a {@link android.util.Printer} that sends its output 21 * to the system log. 22 */ 23public class LogPrinter implements Printer { 24 private final int mPriority; 25 private final String mTag; 26 27 /** 28 * Create a new Printer that sends to the log with the given priority 29 * and tag. 30 * 31 * @param priority The desired log priority: 32 * {@link android.util.Log#VERBOSE Log.VERBOSE}, 33 * {@link android.util.Log#DEBUG Log.DEBUG}, 34 * {@link android.util.Log#INFO Log.INFO}, 35 * {@link android.util.Log#WARN Log.WARN}, or 36 * {@link android.util.Log#ERROR Log.ERROR}. 37 * @param tag A string tag to associate with each printed log statement. 38 */ 39 public LogPrinter(int priority, String tag) { 40 mPriority = priority; 41 mTag = tag; 42 } 43 44 public void println(String x) { 45 Log.println(mPriority, mTag, x); 46 } 47} 48