to top
public class

FileLogger

extends Object
implements ILeveledLogOutput @OptionClass(alias = "file")
java.lang.Object
   ↳ com.android.tradefed.log.FileLogger

Class Overview

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

Summary

Fields
private Log.LogLevel mLogLevel @Option(name = "log-level", description = "the minimum log level to log.")
private Log.LogLevel mLogLevelDisplay @Option(name = "log-level-display", shortName = 108, description = "the minimum log level to display on stdout.", importance = com.android.tradefed.config.Option.Importance.ALWAYS)
private Collection<String> mLogTagsDisplay @Option(name = "log-tag-display", description = "Always display given tags logs on stdout")
private long mMaxLogSizeMbytes @Option(name = "max-log-size", description = "maximum allowable size of tmp log data in mB.")
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.tradefed.log.ILeveledLogOutput
From interface com.android.ddmlib.Log.ILogOutput

Fields

private Log.LogLevel mLogLevel

private Log.LogLevel mLogLevelDisplay

private Collection<String> mLogTagsDisplay

private long mMaxLogSizeMbytes

Public Constructors

public FileLogger ()

Public Methods

public 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

public void closeLog ()

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

public 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

public Log.LogLevel getLogLevel ()

Gets the minimum log level to display.

Returns
Log.LogLevel the current Log.LogLevel

public void init ()

Initialize the log, creating any required IO resources.

Throws
IOException

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

Parameters
logLevel Log.LogLevel
tag String
message String

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

Parameters
logLevel Log.LogLevel
tag String
message String

public void setLogLevel (Log.LogLevel logLevel)

Sets the minimum log level to display.

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