FileSystemLogSaver

public class FileSystemLogSaver
extends Object implements ILogSaver

java.lang.Object
   ↳ com.android.tradefed.result.FileSystemLogSaver


Save logs to a file system.

Summary

Public constructors

FileSystemLogSaver()

Public methods

LogFile getLogReportDir()

Get the LogFile containing the path and/or URL of the directory where logs are saved.

void invocationEnded(long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

void invocationStarted(IInvocationContext context)

Reports the start of the test invocation.

Also, create a unique file system directory under report-dir/[branch/]build-id/test-tag/unique_dir for saving logs.

LogFile saveLogData(String dataName, LogDataType dataType, InputStream dataStream)

Save the log data.

Will zip and save the log file if LogDataType.isCompressed() returns false for dataType and compressed-files is set, otherwise, the stream will be saved uncompressed.

LogFile saveLogDataRaw(String dataName, LogDataType dataType, InputStream dataStream)

A helper method to save the log data unmodified.

Public constructors

FileSystemLogSaver

public FileSystemLogSaver ()

Public methods

getLogReportDir

public LogFile getLogReportDir ()

Get the LogFile containing the path and/or URL of the directory where logs are saved.

Returns
LogFile The LogFile.

invocationEnded

public void invocationEnded (long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

Will be automatically called by the TradeFederation framework after ITestInvocationListener.invocationEnded(long) is called.

Parameters
elapsedTime long: the elapsed time of the invocation in ms

invocationStarted

public void invocationStarted (IInvocationContext context)

Reports the start of the test invocation.

Will be automatically called by the TradeFederation framework before ITestInvocationListener.invocationStarted(IInvocationContext) is called.

Also, create a unique file system directory under report-dir/[branch/]build-id/test-tag/unique_dir for saving logs. If the creation of the directory fails, will write logs to a temporary directory on the local file system.

Parameters
context IInvocationContext: information about the invocation.

saveLogData

public LogFile saveLogData (String dataName, 
                LogDataType dataType, 
                InputStream dataStream)

Save the log data.

Will be automatically called by the TradeFederation framework whenever ITestLogger.testLog(String, LogDataType, InputStreamSource) is called. It may also be used as a helper method to save additional log data.

Depending on the implementation and policy, the logs may be saved in a compressed form. Logs may also be stored in a location inaccessable to Tradefed.

Will zip and save the log file if LogDataType.isCompressed() returns false for dataType and compressed-files is set, otherwise, the stream will be saved uncompressed.

Parameters
dataName String: a String descriptive name of the data. e.g. "device_logcat"

dataType LogDataType: the LogDataType of the file.

dataStream InputStream: the InputStream of the data.

Returns
LogFile the LogFile containing the path and URL of the saved file.

Throws
IOException

saveLogDataRaw

public LogFile saveLogDataRaw (String dataName, 
                LogDataType dataType, 
                InputStream dataStream)

A helper method to save the log data unmodified.

Logs may be stored in a location inaccessible to Tradefed.

Parameters
dataName String: a String descriptive name of the data. e.g. "device_logcat".

dataType LogDataType: a LogDataType containing the type and the extension of the file

dataStream InputStream: the InputStream of the data.

Returns
LogFile the LogFile containing the path and URL of the saved file.

Throws
IOException