示例#1
0
        /*
         * Converts a {@link LogRecord} object into a human readable string
         * representation.
         *
         * @param r
         *            the log record to be formatted into a string.
         * @return the formatted string.
         */

        public override String format(LogRecord r)
        {
            java.lang.StringBuilder sb = new java.lang.StringBuilder();
            sb.append(java.text.MessageFormat.format("{0, date} {0, time} ", //$NON-NLS-1$
                                                     new Object[] { new java.util.Date(r.getMillis()) }));
            sb.append(r.getSourceClassName()).append(" ");                   //$NON-NLS-1$
            sb.append(r.getSourceMethodName()).append(java.lang.SystemJ.getProperty("line.separator"));
            sb.append(r.getLevel().getName()).append(": ");                  //$NON-NLS-1$
            sb.append(formatMessage(r)).append(java.lang.SystemJ.getProperty("line.separator"));
            if (null != r.getThrown())
            {
                sb.append("Throwable occurred: "); //$NON-NLS-1$
                java.lang.Throwable t  = r.getThrown();
                java.io.PrintWriter pw = null;
                try {
                    java.io.StringWriter sw = new java.io.StringWriter();
                    pw = new java.io.PrintWriter(sw);
                    t.printStackTrace(pw);
                    sb.append(sw.toString());
                } finally {
                    if (pw != null)
                    {
                        try {
                            pw.close();
                        } catch (Exception e) {
                            // ignore
                        }
                    }
                }
            }
            return(sb.toString());
        }
示例#2
0
 /**
  * Converts a {@link LogRecord} object into a human readable string
  * representation.
  *
  * @param r
  *            the log record to be formatted into a string.
  * @return the formatted string.
  */
 public override String format(LogRecord r)
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder();
     sb.append(java.text.MessageFormat.format("{0, date} {0, time} ", //$NON-NLS-1$
         new Object[] { new java.util.Date(r.getMillis()) }));
     sb.append(r.getSourceClassName()).append(" "); //$NON-NLS-1$
     sb.append(r.getSourceMethodName()).append(java.lang.SystemJ.getProperty("line.separator"));
     sb.append(r.getLevel().getName()).append(": "); //$NON-NLS-1$
     sb.append(formatMessage(r)).append(java.lang.SystemJ.getProperty("line.separator"));
     if (null != r.getThrown()) {
     sb.append("Throwable occurred: "); //$NON-NLS-1$
     java.lang.Throwable t = r.getThrown();
     java.io.PrintWriter pw = null;
     try {
         java.io.StringWriter sw = new java.io.StringWriter();
         pw = new java.io.PrintWriter(sw);
         t.printStackTrace(pw);
         sb.append(sw.toString());
     } finally {
         if (pw != null) {
             try {
                 pw.close();
             } catch (Exception e) {
                 // ignore
             }
         }
     }
     }
     return sb.toString();
 }
示例#3
0
 /**
  * Returns an XML version of this file
  *
  * @param excludePayload If this is true, the payload will not be included in the XML.
  * @return XML rpm.
  */
 public String toXML(bool excludePayload)
 {
     java.io.StringWriter buf = new java.io.StringWriter();
     try
     {
         toXML(buf, excludePayload);
         buf.flush();
         return(buf.toString());
     }
     catch (java.io.IOException e)
     {
         throw new java.lang.RuntimeException(e);
     }
 }