LogFileSaver
public
class
LogFileSaver
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.result.LogFileSaver
|
A helper for ITestInvocationListener
's that will save log data to a file
Summary
Public methods |
File
|
createCompressedLogFile(String dataName, LogDataType origDataType)
Creates an empty file for storing compressed log data.
|
OutputStream
|
createGZipLogStream(File logFile)
Creates a output stream to write GZIP-compressed data to a file
|
InputStream
|
createInputStreamFromFile(File logFile)
Helper method to create an input stream to read contents of given log fi
TODO: consider moving this method elsewhere.
|
File
|
getFileDir()
Get the directory used to store files.
|
|
getInvocationLogPathSegments()
|
File
|
saveAndGZipLogData(String dataName, LogDataType dataType, InputStream dataStream)
Save and compress, if necessary, the log data to a gzip file
|
File
|
saveAndGZipLogFile(String dataName, LogDataType dataType, File fileToLog)
Save and compress, if necessary, the log data to a gzip file
|
File
|
saveLogData(String dataName, LogDataType dataType, InputStream dataStream)
Save the log data to a file
|
File
|
saveLogDataRaw(String dataName, String ext, InputStream dataStream)
Save raw data to a file
|
File
|
saveLogFile(String dataName, LogDataType dataType, File fileToLog)
Save a given log file
|
Public constructors
LogFileSaver
public LogFileSaver (IBuildInfo buildInfo,
File rootDir)
Creates a LogFileSaver
.
Construct a unique file system directory in rootDir/branch/build_id/uniqueDir
Parameters |
buildInfo |
IBuildInfo : the IBuildInfo |
rootDir |
File : the root file system path |
LogFileSaver
public LogFileSaver (IBuildInfo buildInfo,
File rootDir,
Integer logRetentionDays)
Creates a LogFileSaver
.
Construct a unique file system directory in rootDir/branch/build_id/testTag/uniqueDir
If directory creation fails, will use a temp directory.
Parameters |
buildInfo |
IBuildInfo : the IBuildInfo |
rootDir |
File : the root file system path |
logRetentionDays |
Integer : If provided a '.retention' file will be written to log directory
containing a timestamp equal to current time + logRetentionDays. External cleanup
scripts can use this file to determine when to delete log directories. |
LogFileSaver
public LogFileSaver (File rootDir)
An alternate LogFileSaver
constructor that will just use given directory as the
log storage directory.
Public methods
createCompressedLogFile
public File createCompressedLogFile (String dataName,
LogDataType origDataType)
Creates an empty file for storing compressed log data.
Parameters |
dataName |
String : a String descriptive name of the data to be stored. |
origDataType |
LogDataType : the type of LogDataType to be stored |
Throws |
|
if log file could not be created |
createGZipLogStream
public OutputStream createGZipLogStream (File logFile)
Creates a output stream to write GZIP-compressed data to a file
Returns |
OutputStream |
the ERROR(/OutputStream) to compress and write data to the file.
this stream when complete |
Throws |
|
if stream could not be generated |
public InputStream createInputStreamFromFile (File logFile)
Helper method to create an input stream to read contents of given log fi
TODO: consider moving this method elsewhere. Placed here for now so it e
users of this class to mock.
Returns |
InputStream |
a buffered ERROR(/InputStream) to read file data. Callers must call
this stream when complete |
Throws |
|
if stream could not be generated |
getFileDir
public File getFileDir ()
Get the directory used to store files.
getInvocationLogPathSegments
public getInvocationLogPathSegments ()
Returns |
|
the unique invocation log path segments. |
public File saveAndGZipLogData (String dataName,
LogDataType dataType,
InputStream dataStream)
Save and compress, if necessary, the log data to a gzip file
Returns |
File |
the file of the generated data |
Throws |
|
if log file could not be generated |
saveAndGZipLogFile
public File saveAndGZipLogFile (String dataName,
LogDataType dataType,
File fileToLog)
Save and compress, if necessary, the log data to a gzip file
Returns |
File |
the file of the generated data |
Throws |
|
if log file could not be generated |
public File saveLogData (String dataName,
LogDataType dataType,
InputStream dataStream)
Save the log data to a file
Returns |
File |
the file of the generated data |
Throws |
|
if log file could not be generated |
public File saveLogDataRaw (String dataName,
String ext,
InputStream dataStream)
Save raw data to a file
Parameters |
dataName |
String : a String descriptive name of the data. |
ext |
String : the extension of the date |
dataStream |
InputStream : the ERROR(/InputStream) of the data. |
Returns |
File |
the file of the generated data |
Throws |
|
if log file could not be generated |
saveLogFile
public File saveLogFile (String dataName,
LogDataType dataType,
File fileToLog)
Save a given log file
Parameters |
dataName |
String : a String descriptive name of the data. |
dataType |
LogDataType : the LogDataType of the file. |
fileToLog |
File : the ERROR(/File) to be logged |
Returns |
File |
the file of the generated data |
Throws |
|
if log file could not be generated |