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 saveLogFile(String dataName, LogDataType dataType, File fileToLog)

Save the log file.

void setCompressFiles(boolean compress)

Protected methods

File generateLogReportDir(IBuildInfo buildInfo, File reportDir)

An exposed method that allow subclass to customize generating path logic.

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, com.android.tradefed.result.LogDataType, com.android.tradefed.result.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 inaccessible 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 ERROR(/InputStream) of the data.

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

saveLogFile

public LogFile saveLogFile (String dataName, 
                LogDataType dataType, 
                File fileToLog)

Save the log file.

Will be automatically called by the TradeFederation framework whenever ITestLogger.testLog(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource) is called and the stream references a file.

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

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

dataType LogDataType: the LogDataType of the file.

fileToLog File: the ERROR(/File) to save.

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

setCompressFiles

public void setCompressFiles (boolean compress)

Parameters
compress boolean

Protected methods

generateLogReportDir

protected File generateLogReportDir (IBuildInfo buildInfo, 
                File reportDir)

An exposed method that allow subclass to customize generating path logic.

Parameters
buildInfo IBuildInfo: the IBuildInfo

reportDir File: the ERROR(/File) for the report directory.

Returns
File The directory created.