public class LogMessageStream extends LogMessageBase
OutputStream
as also the System.out
and any other PrintStream
uses bytes for Strings. The encoding depends on settings.
Often only ASCII is expected, whereas (byte)(c) is used from c, a character.
But sometimes also UTF8 is produced.OutputStream
and its implementations for byte-characters
and the Writer
and its implementations for UTF-16, and also the adequate inputs.
Appendable
is a simple interface for UTF16, implemented by the StringBuilder and also for all Writer
.
Hence the other possibility is the simple Appendable as output, which is checked whether it is Closable and Flushable for close and flush.Modifier and Type | Field and Description |
---|---|
(package private) boolean |
closeOnClose
If true than
close() is effective for all associated channels |
private java.text.SimpleDateFormat |
dateFormat |
(package private) java.nio.charset.Charset |
encoding |
(package private) java.io.FileDescriptor |
fd |
(package private) java.io.OutputStream |
out1 |
(package private) java.io.OutputStream |
out2 |
(package private) java.lang.Appendable |
out3 |
(package private) byte[] |
sNewLine
Newline-String, univeral solution not for windows especially (since 2022-09, before it was \r\n.
|
static int |
version
Version, history and license.
|
nLogLevel
debug, error, fineDebug, fineInfo, info, minSecondsFormat, mNeverOutputToDisplay, mReportLevel, sVersion, warning
Constructor and Description |
---|
LogMessageStream(java.io.FileDescriptor fd)
Associates the LogMessageStream with the named opened file.
|
LogMessageStream(java.io.OutputStream out)
Associates the LogMessageStream with the named opened file.
|
LogMessageStream(java.io.OutputStream out1,
java.io.OutputStream out2,
java.lang.Appendable out3,
boolean closeOnClose,
java.nio.charset.Charset encoding)
Associates upto three output channels, all gets the same information.
|
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()
A call of this method closes the devices, which processed the message.
|
static LogMessage |
create(java.io.FileDescriptor fd) |
void |
flush()
A call of this method causes an activating of transmission of all messages since last flush.
|
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.
|
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.io.FileDescriptor fd
final java.io.OutputStream out1
final java.io.OutputStream out2
final java.lang.Appendable out3
final boolean closeOnClose
close()
is effective for all associated channelsfinal java.nio.charset.Charset encoding
byte[] sNewLine
private final java.text.SimpleDateFormat dateFormat
public LogMessageStream(java.io.FileDescriptor fd)
close()
is called.fd
- public LogMessageStream(java.io.OutputStream out)
close()
is called.fd
- public LogMessageStream(java.io.OutputStream out1, java.io.OutputStream out2, java.lang.Appendable out3, boolean closeOnClose, java.nio.charset.Charset encoding)
out1
- any Stream, can be null, for example System.outout2
- any Stream, can be null, for example an opened FileOutputStream
out3
- any Appendable, can be null, can be a Closeable
too.closeOnClose
- true than close()
of this instance closes all associated resourcesCharset
- if null use the default Charset of the JVM, used for the Stream outputs.
It is recommended to set null (default Charset) if System.out is used as output channel.public static LogMessage create(java.io.FileDescriptor fd)
public boolean sendMsgVaList(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, Va_list args)
identNumber
- creationTime
- text
- typeArgs
- Type chars, ZCBSIJFD for boolean, char, byte, short, int, long, float double.args
- see interfacepublic void close()
LogMessage
close
mean.
If the device is a log file writer it should be clearly.
close
may mean, the processing of messages is finite temporary.
An open
occurs automatically, if a new message is dispatched.public void flush()
LogMessage
flush
mean.
If the device is a log file writer it should be clearly.
flush
may mean, the processing of messages is ready to transmit yet.public boolean isOnline()
LogMessage
public boolean sendMsg(int identNumber, java.lang.CharSequence text, java.lang.Object... args)
LogMessage
#sendMsg(int, OS_TimeStamp, String, Object...)
.identNumber
- of the message. If it is negative, it is the same message as positive number,
but with information 'going state', where the positive number is 'coming state'.text
- The text representation of the message, format string, see java.lang.String.format(..).args
- 0, 1 or more arguments of any type.
The interpretation of the arguments is controlled by param text.public boolean sendMsgTime(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, java.lang.Object... args)
LogMessage
identNumber
- of the message. If it is negative, it is the same message as positive number,
but with information 'going state', where the positive number is 'coming state'.creationTime
- absolute time stamp. @Java2C=perValue.text
- The text representation of the message, format string, see java.lang.String.format(..).args
- 0, 1 or more arguments of any type.
The interpretation of the arguments is controlled by param text.public 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