Class LineConfig
java.lang.Object
org.libxmq.LineConfig
Print log lines as xmq, like xmqLinePrintf in xmq.h.
LineConfig lc = new LineConfig();
lc.printf("car{", "nw=", "%d", 36, "model=", "%s", "car go", "}"); // car{nw=36 model='car go'}
lc.printf("work=", "pi is %f", 3.14159); // work='pi is 3.141590'
lc.printf("Fix me!"); // log='Fix me!'
lc.setHumanReadable(true);
lc.printf("work=", "pi is %f", 3.14159); // (work) pi is 3.141590
After an element name ending with { follows a key ending with =, a format and the
arguments the format uses, repeated, and finally "}". The formats are java formats
(String.format, with Locale.ROOT like C printf), the values are quoted as needed.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanIs the output human readable?Print a line.setHumanReadable(boolean enabled) Print human readable lines instead of xmq, eg (work) pi is 3.141590.
-
Constructor Details
-
LineConfig
public LineConfig()Create a line config that prints xmq.
-
-
Method Details
-
setHumanReadable
Print human readable lines instead of xmq, eg (work) pi is 3.141590.- Parameters:
enabled- True for human readable lines.- Returns:
- This line config.
-
humanReadable
public boolean humanReadable()Is the output human readable?- Returns:
- True if human readable.
-
printf
Print a line.- Parameters:
element_name- The element name, ending with { for keys and values, with = for a single value, otherwise it is the text to log.args- The keys, formats and arguments.- Returns:
- The line.
- Throws:
IllegalArgumentException- if a key does not end with =.
-