public interface

ILogFileSaver

com.android.tradefed.result.ILogFileSaver
Known Indirect Subclasses

Class Overview

Saves logs as files.

Summary

Public Methods
abstract File createCompressedLogFile(String dataName, LogDataType origDataType, LogDataType compressedType)
Creates an empty file for storing compressed log data.
abstract OutputStream createGZipLogStream(File dataFile)
Creates a output stream to write GZIP-compressed data to a file
abstract InputStream createInputStreamFromFile(File logFile)
Helper method to create an input stream to read contents of given log file.
abstract File getFileDir()
Get the directory used to store files.
abstract File saveAndZipLogData(String dataName, LogDataType dataType, InputStream dataStream)
Save and compress, if necessary, the log data to a zip file
abstract File saveLogData(String dataName, LogDataType dataType, InputStream dataStream)
Save the log data to a file

Public Methods

public abstract File createCompressedLogFile (String dataName, LogDataType origDataType, LogDataType compressedType)

Creates an empty file for storing compressed log data.

Parameters
dataName a String descriptive name of the data to be stored. e.g. "device_logcat"
origDataType the type of LogDataType to be stored
compressedType the LogDataType representing the compression type. ie one of GZIP or ZIP
Returns
Throws
IOException if log file could not be created

public abstract OutputStream createGZipLogStream (File dataFile)

Creates a output stream to write GZIP-compressed data to a file

Parameters
dataFile the File to write to
Returns
  • the OutputStream to compress and write data to the file. Callers must close this stream when complete
Throws
IOException if stream could not be generated

public abstract InputStream createInputStreamFromFile (File logFile)

Helper method to create an input stream to read contents of given log file.

TODO: consider moving this method elsewhere. Placed here for now so it easier for current users of this class to mock.

Parameters
logFile the File to read from
Returns
  • a buffered InputStream to read file data. Callers must close this stream when complete
Throws
IOException if stream could not be generated

public abstract File getFileDir ()

Get the directory used to store files.

Returns

public abstract File saveAndZipLogData (String dataName, LogDataType dataType, InputStream dataStream)

Save and compress, if necessary, the log data to a zip file

Parameters
dataName a String descriptive name of the data. e.g. "device_logcat"
dataType the LogDataType of the file. Log data which is already compressed, (ie isCompressed() is true) will not be zipped.
dataStream the InputStream of the data.
Returns
  • the file of the generated data
Throws
IOException if log file could not be generated

public abstract File saveLogData (String dataName, LogDataType dataType, InputStream dataStream)

Save the log data to a file

Parameters
dataName a String descriptive name of the data. e.g. "device_logcat"
dataType the LogDataType of the file.
dataStream the InputStream of the data.
Returns
  • the file of the generated data
Throws
IOException if log file could not be generated