FileLogger

public class FileLogger
extends Object implements ILeveledLogOutput

java.lang.Object
   ↳ com.android.tradefed.log.FileLogger
Known Direct Subclasses
HistoryLogger TF History Logger, special log that contains only some specific events. 


A ILeveledLogOutput that directs log messages to a file and to stdout.

Summary

Public constructors

FileLogger()

Public methods

ILeveledLogOutput clone()

Creates a new FileLogger with the same log level settings as the current object.

void closeLog()

Closes the log and performs any cleanup before closing, as necessary.

InputStreamSource getLog()

Grabs a snapshot stream of the log data.

Log.LogLevel getLogLevel()

Gets the minimum log level to display.

void init()

Initialize the log, creating any required IO resources.

void printAndPromptLog(Log.LogLevel logLevel, String tag, String message)

void printLog(Log.LogLevel logLevel, String tag, String message)

void setLogLevel(Log.LogLevel logLevel)

Sets the minimum log level to display.

Protected methods

void init(String logPrefix, String fileSuffix)

Alternative to init() where we can specify the file name and suffix.

Public constructors

FileLogger

FileLogger ()

Public methods

clone

ILeveledLogOutput clone ()

Creates a new FileLogger with the same log level settings as the current object.

Does not copy underlying log file content (ie the clone's log data will be written to a new file.)

Returns
ILeveledLogOutput

closeLog

void closeLog ()

Closes the log and performs any cleanup before closing, as necessary.

getLog

InputStreamSource getLog ()

Grabs a snapshot stream of the log data.

Must not be called after closeLog().

The returned stream is not guaranteed to have optimal performance. Callers may wish to wrap result in a BufferedInputStream.

Returns
InputStreamSource a InputStreamSource of the log data

getLogLevel

Log.LogLevel getLogLevel ()

Gets the minimum log level to display.

Returns
Log.LogLevel the current Log.LogLevel

init

void init ()

Initialize the log, creating any required IO resources.

Throws
IOException

printAndPromptLog

void printAndPromptLog (Log.LogLevel logLevel, 
                String tag, 
                String message)

Parameters
logLevel Log.LogLevel
tag String
message String

printLog

void printLog (Log.LogLevel logLevel, 
                String tag, 
                String message)

Parameters
logLevel Log.LogLevel
tag String
message String

setLogLevel

void setLogLevel (Log.LogLevel logLevel)

Sets the minimum log level to display.

Parameters
logLevel Log.LogLevel: the Log.LogLevel to display

Protected methods

init

void init (String logPrefix, 
                String fileSuffix)

Alternative to init() where we can specify the file name and suffix.

Parameters
logPrefix String: the file name where to log without extension.
fileSuffix String: the extension of the file where to log.