public class LogFile extends java.lang.Object implements ILogEventListener, IExtendedPluginInfo
Modifier and Type | Field and Description |
---|---|
protected int |
mBufferSize
The output buffer size in bytes
|
protected int |
mBytesUnflushed
The number of unflushed bytes
|
protected int |
mBytesWritten
The number of bytes written to the current log file
|
protected IConfigStore |
mConfig |
protected java.util.Date |
mDate
The date object used for log entries
|
protected java.lang.String |
mDatePattern
The log date entry format pattern
|
protected java.io.File |
mFile
The log file
|
protected java.lang.String |
mFileName
The log file name
|
protected int |
mFlushInterval
The output buffer flush interval
|
protected long |
mLevel
The log level threshold
Only logs with level greater or equal than this value will be written
|
protected java.text.SimpleDateFormat |
mLogDateFormat
The log date entry format
|
protected java.text.SimpleDateFormat |
mLogFileDateFormat |
protected boolean |
mLogSigning
Log signing is on/off
|
protected java.io.BufferedWriter |
mLogWriter
The log file output stream
|
protected boolean |
mOn
The log is turned on/off
|
protected int |
mPid
The current pid for the log entries
|
protected boolean |
mRegister
Should this log listener self-register or not
|
protected java.util.Vector |
mSelectedEvents |
protected java.lang.String |
mSelectedEventsList
The selected log event types
|
protected ILogger |
mSignedAuditLogger |
protected boolean |
mTrace |
protected java.lang.String |
mType
The eventType that this log is triggered
|
static java.lang.String |
PROP_LEVEL |
static java.lang.String |
PROP_ON |
static java.lang.String |
PROP_REGISTER |
static java.lang.String |
PROP_SIGNED_AUDIT_CERT_NICKNAME |
static java.lang.String |
PROP_SIGNED_AUDIT_EVENTS |
static java.lang.String |
PROP_SIGNED_AUDIT_LOG_SIGNING |
static java.lang.String |
PROP_TRACE |
static java.lang.String |
PROP_TYPE |
HELP_TEXT, HELP_TOKEN
Constructor and Description |
---|
LogFile()
Constructor for a LogFile.
|
Modifier and Type | Method and Description |
---|---|
protected void |
audit(java.lang.String msg)
Signed Audit Log
This method is inherited by all classes that extend this "LogFile"
class, and is called to store messages to the signed audit log.
|
static java.lang.String |
base64Encode(byte[] bytes) |
protected void |
close()
Close the log file
|
void |
deselectEvent(java.lang.String event)
remove the event from the selected events list
|
void |
flush()
Flush the log file.
|
IConfigStore |
getConfigStore()
Retrieves the configuration store of this subsystem.
|
java.util.Vector |
getDefaultParams()
Return list of default config parameters for this log event listener.
|
java.lang.String |
getDescription()
Returns the description of this log event listener.
|
java.lang.String[] |
getExtendedPluginInfo(java.util.Locale locale)
This method returns an array of strings.
|
java.lang.String |
getImplName()
Returns implementation name.
|
java.util.Vector |
getInstanceParams()
Return list of instance config parameters for this log event listener.
|
long |
getLevel()
Retrieves the log level threshold.
|
java.lang.String |
getName()
Retrieves the base log file name.
|
java.lang.String |
getOn()
Retrieves the log on/off.
|
java.lang.String |
getType()
Retrieves the eventType this log is triggered.
|
void |
init(IConfigStore config)
Initialize and open the log using the parameters from a config store
|
void |
init(ISubsystem owner,
IConfigStore config)
Initialize this log listener
|
void |
init(java.lang.String fileName,
int bufferSize,
int flushInterval)
Initialize and open the log
|
void |
log(ILogEvent ev)
Write an event to the log file
|
protected void |
log(java.lang.String entry)
Synchronized method to write a string to the log file.
|
java.lang.String |
logEvt2String(ILogEvent ev) |
protected void |
open()
Open the log file.
|
java.util.Vector |
readEntry(int maxLine,
int lowLevel,
int source,
java.lang.String fName)
Read all entries whose logLevel>=lowLevel && log source = source
to at most maxLine entries(from end)
If the parameter is -1, it's ignored and return all entries
|
void |
replaceEvents(java.lang.String events)
replace the selected events list
|
NameValuePairs |
retrieveLogContent(java.util.Hashtable req)
Retrieve last "maxLine" number of system log with log lever >"level"
and from source "source".
|
NameValuePairs |
retrieveLogList(java.util.Hashtable req)
Retrieve log file list.
|
void |
selectEvent(java.lang.String event)
add the event to the selected events list
|
void |
setFlushInterval(int flushInterval)
Set the flush interval
|
void |
shutdown()
Shutdown this log file.
|
void |
startup()
Startup the instance
|
protected java.util.Vector |
string2Vector(java.lang.String theString)
turns a comma-separated String into a Vector
|
public static final java.lang.String PROP_TYPE
public static final java.lang.String PROP_REGISTER
public static final java.lang.String PROP_ON
public static final java.lang.String PROP_TRACE
public static final java.lang.String PROP_SIGNED_AUDIT_LOG_SIGNING
public static final java.lang.String PROP_SIGNED_AUDIT_CERT_NICKNAME
public static final java.lang.String PROP_SIGNED_AUDIT_EVENTS
public static final java.lang.String PROP_LEVEL
protected ILogger mSignedAuditLogger
protected IConfigStore mConfig
protected java.text.SimpleDateFormat mLogFileDateFormat
protected java.io.File mFile
protected java.lang.String mFileName
protected java.io.BufferedWriter mLogWriter
protected java.lang.String mDatePattern
protected java.text.SimpleDateFormat mLogDateFormat
protected java.util.Date mDate
protected int mBytesWritten
protected int mBufferSize
protected int mFlushInterval
protected int mBytesUnflushed
protected int mPid
protected java.lang.String mSelectedEventsList
protected java.util.Vector mSelectedEvents
protected java.lang.String mType
protected boolean mOn
protected boolean mRegister
protected boolean mTrace
protected boolean mLogSigning
protected long mLevel
public void init(ISubsystem owner, IConfigStore config) throws EBaseException
ILogEventListener
init
in interface ILogEventListener
owner
- The subsystem.config
- Configuration store for this log listener.EBaseException
protected java.util.Vector string2Vector(java.lang.String theString)
public void selectEvent(java.lang.String event)
event
- to be selectedpublic void deselectEvent(java.lang.String event)
event
- to be de-selectedpublic void replaceEvents(java.lang.String events)
events
- comma-separated event listpublic static java.lang.String base64Encode(byte[] bytes) throws java.io.IOException
java.io.IOException
public void init(IConfigStore config) throws java.io.IOException, EBaseException
config
- The property config store to find values injava.io.IOException
EBaseException
public void init(java.lang.String fileName, int bufferSize, int flushInterval) throws java.io.IOException, ELogException
bufferSize
- The buffer size for the output stream in bytesflushInterval
- The interval in seconds to flush the logjava.io.IOException
ELogException
public void startup() throws EBaseException
startup
in interface ILogEventListener
EBaseException
- if an internal error occurredpublic java.lang.String getType()
public java.lang.String getOn()
public long getLevel()
public java.lang.String getName()
protected void open() throws java.io.IOException
java.io.IOException
public void flush()
flush
in interface ILogEventListener
protected void close()
public void shutdown()
shutdown
in interface ILogEventListener
public void setFlushInterval(int flushInterval)
flushInterval
- The amount of time in seconds until the log
is flush. A value of 0 will disable autoflush. This will also set
the update period for hash protected logs.protected void log(java.lang.String entry) throws ELogException
entry
- The log entry stringELogException
public void log(ILogEvent ev) throws ELogException
log
in interface ILogEventListener
ev
- The event to be logged.ELogException
public java.lang.String logEvt2String(ILogEvent ev)
public java.util.Vector readEntry(int maxLine, int lowLevel, int source, java.lang.String fName)
maxLine
- The maximum lines to be returnedlowLevel
- The lowest log level to be returnedsource
- The particular log source to be returnedfName
- The log file name to be read. If it's null, read the current
log filepublic IConfigStore getConfigStore()
getConfigStore
in interface ILogEventListener
public NameValuePairs retrieveLogContent(java.util.Hashtable req) throws javax.servlet.ServletException, java.io.IOException, EBaseException
retrieveLogContent
in interface ILogEventListener
req
- a Hashtable containing the required information such as
log entry, log level, log source, and log name.javax.servlet.ServletException
- For Servelet errros.java.io.IOException
- For input/output problems.EBaseException
- For other problems.public NameValuePairs retrieveLogList(java.util.Hashtable req) throws javax.servlet.ServletException, java.io.IOException, EBaseException
retrieveLogList
in interface ILogEventListener
javax.servlet.ServletException
java.io.IOException
EBaseException
public java.lang.String getImplName()
ILogEventListener
getImplName
in interface ILogEventListener
public java.lang.String getDescription()
ILogEventListener
getDescription
in interface ILogEventListener
public java.util.Vector getDefaultParams()
ILogEventListener
getDefaultParams
in interface ILogEventListener
public java.util.Vector getInstanceParams()
ILogEventListener
getInstanceParams
in interface ILogEventListener
public java.lang.String[] getExtendedPluginInfo(java.util.Locale locale)
IExtendedPluginInfo
getExtendedPluginInfo
in interface IExtendedPluginInfo
protected void audit(java.lang.String msg)
msg
- signed audit log message