Class LineConfig

java.lang.Object
org.libxmq.LineConfig

public class LineConfig extends Object
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 Details

    • LineConfig

      public LineConfig()
      Create a line config that prints xmq.
  • Method Details

    • setHumanReadable

      public LineConfig setHumanReadable(boolean enabled)
      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

      public String printf(String element_name, Object... args)
      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 =.