1 /* 2 * Copyright (C) 2013 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 package com.example.android.common.logger; 17 18 /** 19 * Simple {@link LogNode} filter, removes everything except the message. 20 * Useful for situations like on-screen log output where you don't want a lot of metadata displayed, 21 * just easy-to-read message updates as they're happening. 22 */ 23 public class MessageOnlyLogFilter implements LogNode { 24 25 LogNode mNext; 26 27 /** 28 * Takes the "next" LogNode as a parameter, to simplify chaining. 29 * 30 * @param next The next LogNode in the pipeline. 31 */ 32 public MessageOnlyLogFilter(LogNode next) { 33 mNext = next; 34 } 35 36 public MessageOnlyLogFilter() { 37 } 38 39 @Override 40 public void println(int priority, String tag, String msg, Throwable tr) { 41 if (mNext != null) { 42 getNext().println(Log.NONE, null, msg, null); 43 } 44 } 45 46 /** 47 * Returns the next LogNode in the chain. 48 */ 49 public LogNode getNext() { 50 return mNext; 51 } 52 53 /** 54 * Sets the LogNode data will be sent to.. 55 */ 56 public void setNext(LogNode node) { 57 mNext = node; 58 } 59 60 }