public static String escape (String s) {
        if (s == null) {
            return "(empty)";
        }

        Matcher m = special.matcher(s);
        if (! m.find()) {
            return s;
        }

        // invariant: we had special characters

        m = backSlash.matcher(s);
        if (m.find()) {
            s = m.replaceAll("\\\\\\\\");
        }

        m = newLine.matcher(s);
        if (m.find()) {
            s = m.replaceAll("\\\\n");
        }

        m = carriage.matcher(s);
        if (m.find()) {
            s = m.replaceAll("\\\\r");
        }

        m = tab.matcher(s);
        if (m.find()) {
            s = m.replaceAll("\\\\t");
        }

        return s;
    }
This static method is used to detect if a message needs
to be escaped, and if so, performs the escaping.  Since the
common case is most likely that escaping is <em>not</em>
needed, the code is optimized for this case.  The forbidden
characters are:

<UL>
 <LI> newline
 <LI> tab
 <LI> backslash
</UL>

<P>
Also handles the case where the message is <code>null</code>
and replaces the null message with a tag saying that the
value was "(empty)".

@param s String that might need escaping
@return returns the escaped string
vespalog/src/main/java/com/yahoo/log/VespaFormat.java