public class PerformanceStatsLog
extends java.lang.Object
implements org.eclipse.osgi.framework.log.FrameworkLog
Clients may extend this class.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BACKUP_MARK
The extension markup to use for backup log files
|
protected boolean |
consoleLog
Indicates if the console messages should be printed to the console (System.out)
|
static int |
DEFAULT_LOG_FILES
The default number of backup log files
|
static int |
DEFAULT_LOG_SIZE
The default size a log file can grow before it is rotated
|
protected static java.lang.String |
ENTRY
The entry tag
|
protected static java.lang.String |
LINE_SEPARATOR
The line separator used in the log output
|
static java.lang.String |
LOG_EXT
The extension used for log files
|
static int |
LOG_SIZE_MIN
The minimum size limit for log rotation
|
protected static java.lang.String |
MESSAGE
The message tag
|
protected boolean |
newSession
Indicates if the next log message is part of a new session
|
protected java.io.File |
outFile
The File object to store messages.
|
static java.lang.String |
PROP_LOG_FILE_MAX
The system property used to specify the maximum number of backup log files to use
|
static java.lang.String |
PROP_LOG_LEVEL
The system property used to specify the log level
|
static java.lang.String |
PROP_LOG_SIZE_MAX
The system property used to specify size a log file can grow before it is rotated
|
static java.lang.String |
PROP_LOGFILE |
protected static java.lang.String |
SESSION
The session tag
|
protected static java.lang.String |
STACK
The stacktrace tag
|
protected static java.lang.String |
SUBENTRY
The sub-entry tag
|
protected static java.lang.String |
TAB_STRING
The tab character used in the log output
|
protected java.io.Writer |
writer
The Writer to log messages to.
|
Constructor and Description |
---|
PerformanceStatsLog(java.io.File outFile) |
PerformanceStatsLog(java.io.Writer writer)
Constructs an EclipseLog which uses the specified Writer to log messages to
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkLogFileSize()
Checks the log file size.
|
void |
close()
Writes the session
|
protected void |
closeFile()
If a File is used to log messages to then the writer is closed.
|
protected java.lang.String |
getDate(java.util.Date date)
Returns a date string using the correct format for the log.
|
java.io.File |
getFile() |
static java.lang.String |
getProperty(java.lang.String key)
Reads the PROP_LOG_SIZE_MAX and PROP_LOG_FILE_MAX properties.
|
protected java.lang.String |
getSessionTimestamp()
Returns the session timestamp.
|
protected java.lang.String |
getStackTrace(java.lang.Throwable t)
Returns a stacktrace string using the correct format for the log
|
void |
log(org.osgi.framework.FrameworkEvent frameworkEvent) |
void |
log(org.eclipse.osgi.framework.log.FrameworkLogEntry logEntry) |
protected java.io.Writer |
logForStream(java.io.OutputStream output)
Returns a Writer for the given OutputStream
|
protected void |
openFile()
If a File is used to log messages to then the File opened and a Writer is created to log messages to.
|
protected void |
readLogProperties() |
void |
setConsoleLog(boolean consoleLog) |
void |
setFile(java.io.File newFile,
boolean append) |
static java.lang.String |
setProperty(java.lang.String key,
java.lang.String value) |
void |
setWriter(java.io.Writer newWriter,
boolean append) |
protected void |
write(java.lang.String message)
Writes the given message to the log.
|
protected void |
writeArgs(java.lang.String header,
java.lang.String[] args)
Helper method for writing out argument arrays.
|
protected void |
writeEntry(int depth,
org.eclipse.osgi.framework.log.FrameworkLogEntry entry)
Writes the ENTRY or SUBENTRY header for an entry.
|
protected void |
writeln()
Writes a newline log.
|
protected void |
writeln(java.lang.String s)
Writes the given message to the log and a newline.
|
protected void |
writeLog(int depth,
org.eclipse.osgi.framework.log.FrameworkLogEntry entry)
Writes the log entry to the log using the specified depth.
|
protected void |
writeMessage(org.eclipse.osgi.framework.log.FrameworkLogEntry entry)
Writes the MESSAGE header to the log for the given entry.
|
protected void |
writeSpace()
Writes a space to the log.
|
protected void |
writeStack(org.eclipse.osgi.framework.log.FrameworkLogEntry entry)
Writes the STACK header to the log for the given entry.
|
protected static final java.lang.String SESSION
protected static final java.lang.String ENTRY
protected static final java.lang.String SUBENTRY
protected static final java.lang.String MESSAGE
protected static final java.lang.String STACK
protected static final java.lang.String LINE_SEPARATOR
protected static final java.lang.String TAB_STRING
public static final int DEFAULT_LOG_SIZE
public static final int DEFAULT_LOG_FILES
public static final int LOG_SIZE_MIN
public static final java.lang.String PROP_LOG_LEVEL
public static final java.lang.String PROP_LOG_SIZE_MAX
public static final java.lang.String PROP_LOG_FILE_MAX
public static final java.lang.String LOG_EXT
public static final java.lang.String BACKUP_MARK
public static final java.lang.String PROP_LOGFILE
protected boolean consoleLog
protected boolean newSession
protected java.io.File outFile
protected java.io.Writer writer
public PerformanceStatsLog(java.io.File outFile)
public PerformanceStatsLog(java.io.Writer writer)
writer
- a writer to log messages toprotected void writeArgs(java.lang.String header, java.lang.String[] args) throws java.io.IOException
header
- the headerargs
- the list of argumentsjava.io.IOException
protected java.lang.String getSessionTimestamp()
public void close()
close
in interface org.eclipse.osgi.framework.log.FrameworkLog
java.io.IOException
- if an error occurs writing to the logprotected void openFile()
protected void closeFile()
public void log(org.osgi.framework.FrameworkEvent frameworkEvent)
log
in interface org.eclipse.osgi.framework.log.FrameworkLog
public void log(org.eclipse.osgi.framework.log.FrameworkLogEntry logEntry)
log
in interface org.eclipse.osgi.framework.log.FrameworkLog
public void setWriter(java.io.Writer newWriter, boolean append)
setWriter
in interface org.eclipse.osgi.framework.log.FrameworkLog
public void setFile(java.io.File newFile, boolean append) throws java.io.IOException
setFile
in interface org.eclipse.osgi.framework.log.FrameworkLog
java.io.IOException
public java.io.File getFile()
getFile
in interface org.eclipse.osgi.framework.log.FrameworkLog
public void setConsoleLog(boolean consoleLog)
setConsoleLog
in interface org.eclipse.osgi.framework.log.FrameworkLog
protected java.lang.String getDate(java.util.Date date)
date
- the Date to formatprotected java.lang.String getStackTrace(java.lang.Throwable t)
t
- the Throwable to get the stacktrace forprotected java.io.Writer logForStream(java.io.OutputStream output)
output
- an OutputStream to use for the Writerprotected void writeLog(int depth, org.eclipse.osgi.framework.log.FrameworkLogEntry entry) throws java.io.IOException
depth
- the depth of th entryentry
- the entry to logjava.io.IOException
- if any error occurs writing to the logprotected void writeEntry(int depth, org.eclipse.osgi.framework.log.FrameworkLogEntry entry) throws java.io.IOException
depth
- the depth of th entryentry
- the entry to write the header forjava.io.IOException
- if any error occurs writing to the logprotected void writeMessage(org.eclipse.osgi.framework.log.FrameworkLogEntry entry) throws java.io.IOException
entry
- the entry to write the message forjava.io.IOException
- if any error occurs writing to the logprotected void writeStack(org.eclipse.osgi.framework.log.FrameworkLogEntry entry) throws java.io.IOException
entry
- the entry to write the stacktrace forjava.io.IOException
- if any error occurs writing to the logprotected void write(java.lang.String message) throws java.io.IOException
message
- the messagejava.io.IOException
- if any error occurs writing to the logprotected void writeln(java.lang.String s) throws java.io.IOException
s
- the messagejava.io.IOException
- if any error occurs writing to the logprotected void writeln() throws java.io.IOException
java.io.IOException
- if any error occurs writing to the logprotected void writeSpace() throws java.io.IOException
java.io.IOException
- if any error occurs writing to the logprotected boolean checkLogFileSize()
public static java.lang.String getProperty(java.lang.String key)
public static java.lang.String setProperty(java.lang.String key, java.lang.String value)
protected void readLogProperties()