public class LogFile extends java.lang.Object implements ILogEventListener, IExtendedPluginInfo
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,netscape.ldap.client.JDAPFilter> |
filters
The event filters
|
protected java.util.Set<java.lang.String> |
mandatoryEvents
The mandatory log event types
|
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 boolean |
mRegister
Should this log listener self-register or not
|
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_FILTERS |
static java.lang.String |
PROP_SIGNED_AUDIT_LOG_SIGNING |
static java.lang.String |
PROP_SIGNED_AUDIT_MANDATORY_EVENTS |
static java.lang.String |
PROP_SIGNED_AUDIT_SELECTED_EVENTS |
static java.lang.String |
PROP_TRACE |
static java.lang.String |
PROP_TYPE |
protected java.util.Set<java.lang.String> |
selectedEvents
The selected log event types
|
HELP_TEXT, HELP_TOKEN
Constructor and Description |
---|
LogFile()
Constructor for a LogFile.
|
Modifier and Type | Method and Description |
---|---|
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
|
protected void |
doLog(ILogEvent event)
Synchronized method to write an event to the log file.
|
boolean |
eval(SignedAuditEvent event,
netscape.ldap.client.JDAPFilter filter) |
boolean |
eval(SignedAuditEvent event,
netscape.ldap.client.JDAPFilterAnd filter) |
boolean |
eval(SignedAuditEvent event,
netscape.ldap.client.JDAPFilterEqualityMatch filter) |
boolean |
eval(SignedAuditEvent event,
netscape.ldap.client.JDAPFilterNot filter) |
boolean |
eval(SignedAuditEvent event,
netscape.ldap.client.JDAPFilterOr filter) |
boolean |
eval(SignedAuditEvent event,
netscape.ldap.client.JDAPFilterPresent filter) |
boolean |
eval(SignedAuditEvent event,
netscape.ldap.client.JDAPFilterSubString filter) |
void |
filter(SignedAuditEvent ev) |
void |
flush()
Flush the log file.
|
IConfigStore |
getConfigStore()
Retrieves the configuration store of this subsystem.
|
java.util.Vector<java.lang.String> |
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<java.lang.String> |
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
|
java.lang.String |
logEvt2String(ILogEvent ev) |
protected void |
open()
Open the log file.
|
java.util.Vector<LogEntry> |
readEntry(int maxLine,
int lowLevel,
LogSource 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<java.lang.String,java.lang.String> req)
Retrieve last "maxLine" number of system log with log lever >"level"
and from source "source".
|
NameValuePairs |
retrieveLogList(java.util.Hashtable<java.lang.String,java.lang.String> 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
|
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_SELECTED_EVENTS
public static final java.lang.String PROP_SIGNED_AUDIT_MANDATORY_EVENTS
public static final java.lang.String PROP_SIGNED_AUDIT_FILTERS
public static final java.lang.String PROP_LEVEL
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 java.util.Set<java.lang.String> mandatoryEvents
protected java.util.Set<java.lang.String> selectedEvents
protected java.util.Map<java.lang.String,netscape.ldap.client.JDAPFilter> filters
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
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 doLog(ILogEvent event) throws ELogException
event
- The log eventELogException
public void log(ILogEvent ev) throws ELogException
log
in interface ILogEventListener
ev
- The event to be logged.ELogException
public void filter(SignedAuditEvent ev) throws ELogException
ELogException
public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilter filter)
public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterPresent filter)
public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterEqualityMatch filter)
public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterSubString filter)
public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterAnd filter)
public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterOr filter)
public boolean eval(SignedAuditEvent event, netscape.ldap.client.JDAPFilterNot filter)
public java.lang.String logEvt2String(ILogEvent ev)
public java.util.Vector<LogEntry> readEntry(int maxLine, int lowLevel, LogSource 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<java.lang.String,java.lang.String> 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<java.lang.String,java.lang.String> 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<java.lang.String> getDefaultParams()
ILogEventListener
getDefaultParams
in interface ILogEventListener
public java.util.Vector<java.lang.String> getInstanceParams()
ILogEventListener
getInstanceParams
in interface ILogEventListener
public java.lang.String[] getExtendedPluginInfo(java.util.Locale locale)
IExtendedPluginInfo
getExtendedPluginInfo
in interface IExtendedPluginInfo