public class LogMessageFile extends LogMessageBase
Modifier and Type | Class and Description |
---|---|
(package private) static class |
LogMessageFile.Dbg
Helper class for some debug informations.
|
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
bNewFile |
(package private) char[] |
charsFormatTimestampFilename |
(package private) int |
cntAllNonFlushedWrite
Counts all non flushed writes (seconds without flush).
|
(package private) int |
cntNonFlushedWrite
Counts all non flushed writes in a flush period.
|
(package private) int |
counterMultifile
Actual counter of multiFile.
|
(package private) int |
currentLengthMultifileNr |
private java.text.SimpleDateFormat |
dateFormat
The date format is fix.
|
(package private) LogMessageFile.Dbg |
dbg |
(package private) FileAppend |
file |
(package private) java.text.FieldPosition |
formatField |
(package private) java.text.SimpleDateFormat |
formatTimestamp |
(package private) ConcurrentLinkedQueue<MsgDispatcherCore.Entry> |
freeEntries
Common pool of entries to save messages.
|
static int |
kMsgClose |
static int |
kMsgNewFile |
static int |
kMsgOpen |
static int |
kMsgOpenError |
private java.util.Locale |
localization |
(package private) int |
maxCntNonFlushedWrite
Little statistic: max nr of writes without flush.
|
(package private) int |
msgIdentOpenClose
Number for open and close message.
|
(package private) LogMessage |
msgOpenClose
An open or close operation may be logged.
|
(package private) int |
nrofHoursPerFile
-1 than close never automaticly.
|
(package private) int |
nrofSecondsToClose |
(package private) int |
nrofSecondsToFlush |
(package private) ConcurrentLinkedQueue<MsgDispatcherCore.Entry> |
parkedOrders
List of messages to process if the file is able to open.
|
(package private) int |
posMultifileInFilename
If it is -1, no multiFile designation is used.
|
(package private) int |
posTimestampInFilename |
private java.lang.StringBuilder |
sBuffer
Buffer for the current line to assign.
|
(package private) java.lang.StringBuffer |
sDateformatBuffer
StringBuilder to store the converted timeStamp for file time.
|
(package private) java.lang.StringBuilder |
sFilenameBuffer |
(package private) java.lang.String |
sFormatTimestampFilename
TODO
|
(package private) boolean |
shouldFlushed |
(package private) OS_TimeStamp |
timeClose
The last close time.
|
(package private) OS_TimeStamp |
timeOpen
All OS:TimeStamp are simple embedded instances in C,
but derived instances from java.util.Data in java.
|
(package private) OS_TimeStamp |
timeWrite |
private java.util.TimeZone |
timeZone |
static int |
version
Version, history and license.
|
nLogLevel
debug, error, fineDebug, fineInfo, info, minSecondsFormat, mNeverOutputToDisplay, mReportLevel, sVersion, warning
Constructor and Description |
---|
LogMessageFile(java.lang.String sFilename,
int nrofSecondsToFlush,
int nrofHoursPerFile,
java.util.Locale localization,
java.util.TimeZone timeZoneP,
ConcurrentLinkedQueue<MsgDispatcherCore.Entry> freeEntriesP)
Constructs the instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Appendable |
append(char c) |
java.lang.Appendable |
append(java.lang.CharSequence csq) |
java.lang.Appendable |
append(java.lang.CharSequence csq,
int start,
int end) |
void |
close()
Closes the file and forces usage of a new file on next open.
|
void |
flush()
This method can be called after a cyclic time less than the nrofSecondsToFlush,
but in the same thread like writing.
|
boolean |
isOnline()
Checks whether the message output is available.
|
boolean |
sendMsg(int identNumber,
java.lang.CharSequence text,
java.lang.Object... args)
Sends a message.
|
boolean |
sendMsgTime(int identNumber,
OS_TimeStamp creationTime,
java.lang.CharSequence text,
java.lang.Object... args)
Sends a message.
|
boolean |
sendMsgVaList(int identNumber,
OS_TimeStamp creationTime,
java.lang.CharSequence text,
Va_list args)
Sends a message.
|
void |
setLogMessageOpenClose(LogMessage msg,
int msgIdentOpenClose)
Sets a log output if a open or close action is done.
|
(package private) void |
writeInFile(int identNumber,
OS_TimeStamp creationTime,
java.lang.CharSequence text,
Va_list args)
Tests
|
flushReport, getReportLevel, getReportLevelFromIdent, report, report, reportln, reportln, setReportLevel, setReportLevelToIdent, writeError, writeError, writeInfo, writeInfoln, writeWarning
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
msgSec, timeCurr, timeMsg
public static final int version
final java.lang.StringBuilder sFilenameBuffer
final java.lang.StringBuffer sDateformatBuffer
SimpleDateFormat.format(java.util.Date, StringBuffer, FieldPosition)
java.lang.String sFormatTimestampFilename
final java.text.SimpleDateFormat formatTimestamp
int counterMultifile
final java.text.FieldPosition formatField
final char[] charsFormatTimestampFilename
int posTimestampInFilename
int posMultifileInFilename
int currentLengthMultifileNr
final FileAppend file
final OS_TimeStamp timeOpen
boolean bNewFile
final OS_TimeStamp timeWrite
final OS_TimeStamp timeClose
final int nrofSecondsToFlush
final int nrofSecondsToClose
int cntAllNonFlushedWrite
int cntNonFlushedWrite
int maxCntNonFlushedWrite
boolean shouldFlushed
LogMessage msgOpenClose
int msgIdentOpenClose
public static final int kMsgOpen
public static final int kMsgNewFile
public static final int kMsgOpenError
public static final int kMsgClose
int nrofHoursPerFile
final LogMessageFile.Dbg dbg
final ConcurrentLinkedQueue<MsgDispatcherCore.Entry> parkedOrders
final ConcurrentLinkedQueue<MsgDispatcherCore.Entry> freeEntries
private final java.text.SimpleDateFormat dateFormat
private final java.util.Locale localization
private final java.util.TimeZone timeZone
private final java.lang.StringBuilder sBuffer
public LogMessageFile(java.lang.String sFilename, int nrofSecondsToFlush, int nrofHoursPerFile, java.util.Locale localization, java.util.TimeZone timeZoneP, ConcurrentLinkedQueue<MsgDispatcherCore.Entry> freeEntriesP)
sFilename
- path and name.
"path/name_$MMM-ddhh_mm$.log"
produces a filename at ex.
"path/name_Jan27-1233.log"
.
nrofSecondsToFlush
- If negative, than the file will closed after this time of opend file.
The file will be in closing state at least this time.
nrofHoursPerFile
- 1... the time in hours, after which a new file is created.
0: A new file isn't created.
-1.. the time in seconds, after which a new file is created (only to use for test).freeEntriesP
- A pool of free entries, managed by a ConcurrentLinkedQueue.public void setLogMessageOpenClose(LogMessage msg, int msgIdentOpenClose)
msg
- The message output may be the message dispatcher, and the message may be sent
to this instance itself, it is no problem.msgIdentOpenClose
- The msg ident number for the open message. The close message is +1.public boolean sendMsg(int identNumber, java.lang.CharSequence text, java.lang.Object... args)
identNumber
- text
- The text representation of the message, format string, see java.lang.String.format(..).args
- see interfacepublic final boolean sendMsgTime(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, java.lang.Object... args)
identNumber
- creationTime
- text
- The text representation of the message, format string, see java.lang.String.format(..).args
- see interfacepublic boolean sendMsgVaList(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, Va_list args)
identNumber
- creationTime
- text
- The text representation of the message, format string, see java.lang.String.format(..).typeArgs
- Type chars, ZCBSIJFD for boolean, char, byte, short, int, long, float double.args
- see interfacepublic java.lang.Appendable append(java.lang.CharSequence csq) throws java.io.IOException
java.io.IOException
public java.lang.Appendable append(java.lang.CharSequence csq, int start, int end) throws java.io.IOException
java.io.IOException
public java.lang.Appendable append(char c) throws java.io.IOException
java.io.IOException
public void flush()
void writeInFile(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, Va_list args)
identNumber
- creationTime
- text
- The text representation of the message, format string, see java.lang.String.format(..).args
- public void close()
public boolean isOnline()
LogMessage