public interface LogMessage
extends java.lang.Appendable, java.io.Closeable
LogMessageStream
.
That uses LogMessageBase
which adapts the operations here to more simple outputs.
MsgDispatcher
implements this interface for full numbered messages
with selection of the messages by number.
writeInfoln(CharSequence)
etc. are responsible.
writeInfo(String, Object...)
, writeInfoAdd(String, Object...)
writeWarning(String, Object...)
, writeWarningAdd(String, Object...)
writeError(String, Object...)
, writeErrorAdd(String, Object...)
String.format(String, Object...)
formats it.
sendMsg(int, CharSequence, Object...)
,
sendMsgTime(int, OS_TimeStamp, CharSequence, Object...)
,
sendMsgVaList(int, OS_TimeStamp, CharSequence, Va_list)
are responsible.
String.format(String, Object...)
-Method should used to display the text.
But the values may be also important for evaluating the message in the destination.
The meaning of the values depends on the kind of message, identified by the number.
java.util.Date
Object.
In a realtime system, compiled with C-Language, the struct Date may have a microsecond resolution
and another base year, but it should be absolute.Modifier and Type | Field and Description |
---|---|
static java.text.SimpleDateFormat |
dateFormat
It should be implemented especially for a File-Output to flush or close
the file in a raster of some seconds.
|
static int |
debug
report level to indicate the report should be written to detect problems in software.
|
static int |
error
report level to indicate the report should be written anytime and anyway.
|
static int |
fineDebug
report level to indicate all report should be written to detect problems in software with finely and heavyset reports.
|
static int |
fineInfo
report level to indicate the report should be written if a user is interested on the order of the events finely.
|
static int |
info
report level to indicate the report should be written if a user is interested on notes of the progression of programm is working.
|
static java.text.SimpleDateFormat |
minSecondsFormat |
static int |
mNeverOutputToDisplay
Mask bit to indicate, do not write to display.
|
static int |
mReportLevel
Mask for the in fact reportlevel, other bits may have another meaning.
|
static java.lang.String |
sVersion
Version, history and license.
|
static int |
warning
report level to indicate the report should be written if a user is interested on warnings.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
A call of this method closes the devices, which processed the message.
|
void |
flush()
A call of this method causes an activating of transmission of all messages since last flush.
|
void |
flushReport()
Writes the content in the physical medium.
|
int |
getReportLevel()
access to the level of report.
|
int |
getReportLevelFromIdent(int ident)
gets the associated report level to a report identifier.
|
boolean |
isOnline()
Checks whether the message output is available.
|
static java.lang.String |
msgSec(java.lang.String msg,
long ms)
It prepares a message part with given mm:ss.SSS (till millisec accuracy) with a given absolute time.
|
void |
report(java.lang.CharSequence startText,
java.lang.Throwable exception)
report of a excpetion (in a new line)
|
void |
report(int nLevel,
java.lang.CharSequence string)
report inside a line
|
void |
reportln(int nLevel,
java.lang.CharSequence string)
report begins at a new a line
|
void |
reportln(int nLevel,
int nLeftMargin,
java.lang.CharSequence string)
report begins at a new a line with left margin
|
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.
|
int |
setReportLevel(int level)
Set another level inside programming.
|
void |
setReportLevelToIdent(int ident,
int nLevelActive)
Sets a dedicated level number to the known output priorities.
|
static java.lang.String |
timeCurr(java.lang.String msg)
It prepares a message with the current time and a String after it.
|
static java.lang.String |
timeMsg(long ms,
java.lang.String msg)
This is a simple static output operation independent of the log system.
|
void |
writeError(java.lang.CharSequence sError)
Writes an error line.
|
void |
writeError(java.lang.String text,
java.lang.Object... args)
Writes a beginning new line with the prepared text to an error output.
|
void |
writeError(java.lang.String CharSequence,
java.lang.Throwable exc)
Writes an error line caused by an exception.
|
void |
writeErrorAdd(java.lang.String text,
java.lang.Object... args)
Writes an additional information for the error message after the already outputted error line in the same line.
|
void |
writef(java.lang.String text,
java.lang.Object... args)
Writes the prepared text to the log as information.
|
void |
writeInfo(java.lang.CharSequence sInfo)
Appends an info to the end of the previous info, @see
writeInfoln(CharSequence) . |
void |
writeInfo(java.lang.String text,
java.lang.Object... args)
Writes the prepared text to the log as information.
|
void |
writeInfoAdd(java.lang.String text,
java.lang.Object... args)
Writes an additional information for the info message after the already output info line in the same line.
|
void |
writeInfoln(java.lang.CharSequence sInfo)
Writes an info line.
|
void |
writeWarning(java.lang.CharSequence sError)
Writes an error line.
|
void |
writeWarning(java.lang.String text,
java.lang.Object... args)
Writes a beginning new line with the prepared text to an standard or warning output.
|
void |
writeWarningAdd(java.lang.String text,
java.lang.Object... args)
Writes an additional information for the warning message after the already outputt warning line in the same line.
|
static final java.lang.String sVersion
timeCurr(String)
etc.
timeMsg(long, String)
as helper for simple preparation an String with timestamp in absolute in ms.
MainCmdLogging_ifc
are moved to this.
It makes possible that some programs such as ZbnfParser
now uses the basically LogMessage
instead the older and more complex MainCmdLogging_ifc.
Default implementations for all additional operations are contains in LogMessageBase
.
#writeError(String)
is declared in MainCmd_ifc
and used sometimes. It is also yet defined here, but redirected to Appendable.append(CharSequence)
in the new LogMessageBase implementation.
LogMessageStream
.
#sendMsg(int, String, Object...)
described.
It was not defined and maybe not used in the last 8 years.
static final int error
static final int warning
static final int info
static final int fineInfo
static final int debug
static final int fineDebug
static final int mReportLevel
static final int mNeverOutputToDisplay
static final java.text.SimpleDateFormat dateFormat
MsgDispatcher.DispatcherThread.run()
.static final java.text.SimpleDateFormat minSecondsFormat
boolean sendMsg(int identNumber, java.lang.CharSequence text, java.lang.Object... args)
#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.boolean sendMsgTime(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, java.lang.Object... args)
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.boolean sendMsgVaList(int identNumber, OS_TimeStamp creationTime, java.lang.CharSequence text, Va_list args)
#sendMsg(int, OS_TimeStamp, String, Object...)
, but the parameter args is varied:identNumber
- creationTime
- text
- The text of the message: Hint for Java2C: This is a StringJc, not a simple char const*.
That is necessary because the String may be replaced.typeArgs
- Type chars, ZCBSIJFD for boolean, char, byte, short, int, long, float double.args
- Reference to a buffer which contains the values for a variable argument list.
vprintf(buffer, text, args)
.
The referenced instance shouldn't accepted as persistent outside processing time
of the called routine. Therefore stack content is able to provide.
void writeInfoln(java.lang.CharSequence sInfo)
sInfo
- String to be written.void writeInfo(java.lang.CharSequence sInfo)
writeInfoln(CharSequence)
.sInfo
- String to be written.void writeWarning(java.lang.CharSequence sError)
sError
- The error text, it should be without such hot spot words line "!!!WARNING!!!",
because the distinction in display should be done by the implementation of this method.
A good sample is writeErrorln("file is empty: " + sFileName);void writeError(java.lang.CharSequence sError)
sError
- The error text, it should be without such hot spot words line "!!!ERROR!!!",
because the distinction in display should be done by the implementation of this method.
A good sample is writeErrorln("cannot create file: " + sFileName);void writef(java.lang.String text, java.lang.Object... args)
text
- should begin with "\n", can be contain format placeholder, String.format(String, Object...)
is usedargs
- The args for the placeholder.void writeInfo(java.lang.String text, java.lang.Object... args)
text
- should begin with "\n", can be contain format placeholder, String.format(String, Object...)
is usedargs
- The args for the placeholder.void writeInfoAdd(java.lang.String text, java.lang.Object... args)
text
- can be contain format placeholder, String.format(String, Object...)
is usedargs
- The args for the placeholder.writeError(String, Object...)
void writeWarning(java.lang.String text, java.lang.Object... args)
text
- can be contain format placeholder, String.format(String, Object...)
is usedargs
- The args for the placeholder.void writeWarningAdd(java.lang.String text, java.lang.Object... args)
text
- can be contain format placeholder, String.format(String, Object...)
is usedargs
- The args for the placeholder.writeError(String, Object...)
void writeError(java.lang.String text, java.lang.Object... args)
text
- can be contain format placeholder, String.format(String, Object...)
is usedargs
- The args for the placeholder.void writeErrorAdd(java.lang.String text, java.lang.Object... args)
text
- can be contain format placeholder, String.format(String, Object...)
is usedargs
- The args for the placeholder.writeError(String, Object...)
void writeError(java.lang.String CharSequence, java.lang.Throwable exc)
sError
- The error text, it should be without such hot spot words line "!!!ERROR!!!",
because the distinction in display should be done by the implementation of this method.
A good sample is writeErrorln("cannot create file: " + sFileName);exc
- The catched Exception. The getMessage()-part of the exception is written after sError.
The stacktrace of the exception is written to report.void report(int nLevel, java.lang.CharSequence string)
void reportln(int nLevel, int nLeftMargin, java.lang.CharSequence string)
nLevel
- write the report only if the demand level is greater or equal.nLeftMargin
- determins a left margin. First a new line is outputted, followed by '*' and spaces.string
- String to write.void reportln(int nLevel, java.lang.CharSequence string)
nLevel
- write the report only if the demand level is greater or equal.string
- String to write.void report(java.lang.CharSequence startText, java.lang.Throwable exception)
int getReportLevel()
void flushReport()
void setReportLevelToIdent(int ident, int nLevelActive)
nLevel
- The number identifying a dedicated level. This number should be greater than
the known priority levels, it means >= 10 or >=1000.
Use dedicated group of numbers for an application.nLevelActive
- Ones of the known priotity levels Report.error
to Report.fineDebug
.
class MyModule { /**Define module-specific numbers to identify a level. * The numbers should be define regarding a band of numbers in the application. * / static final int myReportLevel1 = 3500, myReportLevel2=3501; void init() { setLevelActive(myReportLevel1, Report.info); //This reports should be outputted always setLevelActive(myReportLevel2, Report.debug); //This reports are debug infos. } void processAnything() { report.reportln( myReportLevel1, "InfoText"); //It depends on the report level settings report.reportln( myReportLevel2, "DebugText");//whether it is outputed or not. }
int setReportLevel(int level)
int getReportLevelFromIdent(int ident)
ident
- The identifier.void close()
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.close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
void flush()
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.boolean isOnline()
static java.lang.String timeMsg(long ms, java.lang.String msg)
ms
- Milliseconds after 1970msg
- static java.lang.String msgSec(java.lang.String msg, long ms)
msg
- Text before, shold have the form "time=" or "at " or such.ms
- absolute time for the millisecstatic java.lang.String timeCurr(java.lang.String msg)
msg
- any text.