|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.runtime.adaptor.EclipseLog
public class EclipseLog
The FrameworkLog implementation for Eclipse.
Clients may extend this class.
Field Summary | |
---|---|
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 maximim 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 |
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. |
Fields inherited from interface org.eclipse.osgi.framework.log.FrameworkLog |
---|
SERVICE_PERFORMANCE |
Constructor Summary | |
---|---|
EclipseLog()
Constructs an EclipseLog which uses System.err to write log messages to |
|
EclipseLog(java.io.File outFile)
Constructs an EclipseLog which uses the specified File to log messages to |
|
EclipseLog(java.io.Writer writer)
Constructs an EclipseLog which uses the specified Writer to log messages to |
Method Summary | |
---|---|
protected boolean |
checkLogFileSize()
Checks the log file size. |
void |
close()
Closes the FrameworkLog. |
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()
Returns the log File if it is set, otherwise null is returned. |
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(FrameworkEvent frameworkEvent)
Logs the information from a FrameworkEvent to the FrameworkLog. |
void |
log(FrameworkLogEntry logEntry)
Logs the FrameworkLogEntry to the FrameworkLog |
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()
Reads the PROP_LOG_SIZE_MAX and PROP_LOG_FILE_MAX properties. |
void |
setConsoleLog(boolean consoleLog)
Sets the console log option. |
void |
setFile(java.io.File newFile,
boolean append)
Sets the current File used to log messages to a FileWriter using the specified File. |
void |
setWriter(java.io.Writer newWriter,
boolean append)
Sets the current Writer used to log messages to the specified newWriter. |
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,
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,
FrameworkLogEntry entry)
Writes the log entry to the log using the specified depth. |
protected void |
writeMessage(FrameworkLogEntry entry)
Writes the MESSAGE header to the log for the given entry. |
protected void |
writeSession()
Writes the session |
protected void |
writeSpace()
Writes a space to the log. |
protected void |
writeStack(FrameworkLogEntry entry)
Writes the STACK header to the log for the given entry. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
protected boolean consoleLog
protected boolean newSession
protected java.io.File outFile
protected java.io.Writer writer
Constructor Detail |
---|
public EclipseLog(java.io.File outFile)
outFile
- a file to log messages topublic EclipseLog(java.io.Writer writer)
writer
- a writer to log messages topublic EclipseLog()
Method Detail |
---|
protected void writeArgs(java.lang.String header, java.lang.String[] args) throws java.io.IOException
header
- the headerargs
- the list of arguments
java.io.IOException
protected java.lang.String getSessionTimestamp()
protected void writeSession() throws java.io.IOException
java.io.IOException
- if an error occurs writing to the logpublic void close()
FrameworkLog
close
in interface FrameworkLog
protected void openFile()
protected void closeFile()
public void log(FrameworkEvent frameworkEvent)
FrameworkLog
log
in interface FrameworkLog
frameworkEvent
- The FrameworkEvent to log.public void log(FrameworkLogEntry logEntry)
FrameworkLog
log
in interface FrameworkLog
logEntry
- The entry to log.public void setWriter(java.io.Writer newWriter, boolean append)
FrameworkLog
setWriter
in interface FrameworkLog
newWriter
- The Writer to use for logging messages.append
- Indicates whether the content of the current Writer
used for logging messages should be appended to the end of the new
Writer.public void setFile(java.io.File newFile, boolean append) throws java.io.IOException
FrameworkLog
setFile
in interface FrameworkLog
newFile
- The File to create a new FileWriter which will be
used for logging messages.append
- Indicates whether the content of the current Writer
used for logging messages should be appended to the end of the new
File.
java.io.IOException
- if any problem occurs while constructing a
FileWriter from the newFile. If this exception is thrown the
FrameworkLog will not be effected and will continue to use the
current Writer to log messages.public java.io.File getFile()
FrameworkLog
getFile
in interface FrameworkLog
public void setConsoleLog(boolean consoleLog)
FrameworkLog
setConsoleLog
in interface FrameworkLog
consoleLog
- indicates whether to log to System.outprotected java.lang.String getDate(java.util.Date date)
date
- the Date to format
protected java.lang.String getStackTrace(java.lang.Throwable t)
t
- the Throwable to get the stacktrace for
protected java.io.Writer logForStream(java.io.OutputStream output)
output
- an OutputStream to use for the Writer
protected void writeLog(int depth, FrameworkLogEntry entry) throws java.io.IOException
depth
- the depth of th entryentry
- the entry to log
java.io.IOException
- if any error occurs writing to the logprotected void writeEntry(int depth, FrameworkLogEntry entry) throws java.io.IOException
depth
- the depth of th entryentry
- the entry to write the header for
java.io.IOException
- if any error occurs writing to the logprotected void writeMessage(FrameworkLogEntry entry) throws java.io.IOException
entry
- the entry to write the message for
java.io.IOException
- if any error occurs writing to the logprotected void writeStack(FrameworkLogEntry entry) throws java.io.IOException
entry
- the entry to write the stacktrace for
java.io.IOException
- if any error occurs writing to the logprotected void write(java.lang.String message) throws java.io.IOException
message
- the message
java.io.IOException
- if any error occurs writing to the logprotected void writeln(java.lang.String s) throws java.io.IOException
s
- the message
java.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()
protected void readLogProperties()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |