Home | History | Annotate | Download | only in log
      1 /*
      2  * Copyright (C) 2010 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.android.tradefed.log;
     17 
     18 import com.android.ddmlib.Log.ILogOutput;
     19 import com.android.ddmlib.Log.LogLevel;
     20 import com.android.tradefed.result.InputStreamSource;
     21 
     22 import java.io.BufferedInputStream;
     23 import java.io.IOException;
     24 
     25 /**
     26  * Classes which implement this interface provides methods that deal with outputting log
     27  * messages.
     28  */
     29 public interface ILeveledLogOutput extends ILogOutput {
     30 
     31     /**
     32      * Initialize the log, creating any required IO resources.
     33      */
     34     public void init() throws IOException;
     35 
     36     /**
     37      * Gets the minimum log level to display.
     38      *
     39      * @return the current {@link LogLevel}
     40      */
     41     public LogLevel getLogLevel();
     42 
     43     /**
     44      * Sets the minimum log level to display.
     45      *
     46      * @param logLevel the {@link LogLevel} to display
     47      */
     48     public void setLogLevel(LogLevel logLevel);
     49 
     50     /**
     51      * Grabs a snapshot stream of the log data.
     52      * <p/>
     53      * Must not be called after {@link ILeveledLogOutput#closeLog()}.
     54      * <p/>
     55      * The returned stream is not guaranteed to have optimal performance. Callers may wish to
     56      * wrap result in a {@link BufferedInputStream}.
     57      *
     58      * @return a {@link InputStreamSource} of the log data
     59      * @throws IllegalStateException if called when log has been closed.
     60      */
     61     public InputStreamSource getLog();
     62 
     63     /**
     64      * Closes the log and performs any cleanup before closing, as necessary.
     65      */
     66     public void closeLog();
     67 
     68     /**
     69      * @return a {@link ILeveledLogOutput}
     70      */
     71     public ILeveledLogOutput clone();
     72 }
     73