LogRegistry

public class LogRegistry
extends Object implements ILogRegistry

java.lang.Object
   ↳ com.android.tradefed.log.LogRegistry


A ILogRegistry implementation that multiplexes and manages different loggers, using the appropriate one based on the ThreadGroup of the thread making the call.

Note that the registry hashes on the ThreadGroup in which a thread belongs. If a thread is spawned with its own explicitly-supplied ThreadGroup, it will not inherit the parent thread's logger, and thus will need to register its own logger with the LogRegistry if it wants to log output.

Summary

Public methods

void closeAndRemoveAllLogs()

Closes and removes all logs being managed by this LogRegistry.

void dumpLogs()

Diagnosis method to dump all logs to files.

void dumpLogsToDir(File dir)

Save the log data to files in the specified directory.

void dumpToGlobalLog(ILeveledLogOutput log)

Dumps the entire contents of a ILeveledLogOutput logger to the global log.

Log.LogLevel getGlobalLogDisplayLevel()

Returns current log level display for the global log

static ILogRegistry getLogRegistry()

Get the LogRegistry instance

void logEvent(Log.LogLevel logLevel, ILogRegistry.EventType event, Map<String, String> args)

Call this method to log an event from a type with the associated information in the map.

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

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

void registerLogger(ILeveledLogOutput log)

Registers the logger as the instance to use for the current thread.

void saveGlobalLog()

Saves all the global loggers contents to tmp files.

void setGlobalLogDisplayLevel(Log.LogLevel logLevel)

Set the log level display for the global log

void setGlobalLogTagDisplay(Collection<String> logTagsDisplay)

Set the log tags to display for the global log

void unregisterLogger()

Unregisters the current logger in effect for the current thread.

Public methods

closeAndRemoveAllLogs

void closeAndRemoveAllLogs ()

Closes and removes all logs being managed by this LogRegistry.

dumpLogs

void dumpLogs ()

Diagnosis method to dump all logs to files.

dumpLogsToDir

void dumpLogsToDir (File dir)

Save the log data to files in the specified directory.

Parameters
dir File: directory to save file, can be null, file will be saved in tmp directory.

dumpToGlobalLog

void dumpToGlobalLog (ILeveledLogOutput log)

Dumps the entire contents of a ILeveledLogOutput logger to the global log.

This is useful in scenarios where you know the logger's output won't be saved permanently, yet you want the contents to be saved somewhere and not lost.

getGlobalLogDisplayLevel

Log.LogLevel getGlobalLogDisplayLevel ()

Returns current log level display for the global log

Returns
Log.LogLevel logLevel the Log.LogLevel to use

getLogRegistry

ILogRegistry getLogRegistry ()

Get the LogRegistry instance

Returns
ILogRegistry a LogRegistry that can be used to register, get, write to, and close logs

logEvent

void logEvent (Log.LogLevel logLevel, 
                ILogRegistry.EventType event, 
                Map<String, String> args)

Call this method to log an event from a type with the associated information in the map. Time of the event is automatically added.

Parameters
logLevel Log.LogLevel: the Log.LogLevel to be printed.
event ILogRegistry.EventType: the ILogRegistry.EventType of the event to log.
args Map: the map of arguments to be added to the log entry to get more details on the event.

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

registerLogger

void registerLogger (ILeveledLogOutput log)

Registers the logger as the instance to use for the current thread.

Parameters
log ILeveledLogOutput

saveGlobalLog

void saveGlobalLog ()

Saves all the global loggers contents to tmp files.

setGlobalLogDisplayLevel

void setGlobalLogDisplayLevel (Log.LogLevel logLevel)

Set the log level display for the global log

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

setGlobalLogTagDisplay

void setGlobalLogTagDisplay (Collection<String> logTagsDisplay)

Set the log tags to display for the global log

Parameters
logTagsDisplay Collection

unregisterLogger

void unregisterLogger ()

Unregisters the current logger in effect for the current thread.