Ejemplo n.º 1
0
 static {
   MLevel dflt = null;
   String dfltName =
       MLog.CONFIG.getProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL");
   if (dfltName != null) dflt = MLevel.fromSeverity(dfltName);
   if (dflt == null) dflt = MLevel.INFO;
   DEFAULT_CUTOFF_LEVEL = dflt;
 }
  static {
    MLevel dflt = null;
    String dfltName =
        MLogConfig.getProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL");
    if (dfltName != null) dflt = MLevel.fromSeverity(dfltName);
    if (dflt == null) dflt = MLevel.INFO;
    DEFAULT_CUTOFF_LEVEL = dflt;

    SEP = System.getProperty("line.separator");
  }
    private String formatString(
        MLevel l, String srcClass, String srcMeth, String msg, Object[] params, Throwable t) {
      boolean add_parens = (srcMeth != null && !srcMeth.endsWith(")"));

      StringBuffer sb = new StringBuffer(256);
      sb.append(l.getLineHeader());
      sb.append(' ');
      if (srcClass != null && srcMeth != null) {
        sb.append('[');
        sb.append(srcClass);
        sb.append('.');
        sb.append(srcMeth);
        if (add_parens) sb.append("()");
        sb.append(']');
      } else if (srcClass != null) {
        sb.append('[');
        sb.append(srcClass);
        sb.append(']');
      } else if (srcMeth != null) {
        sb.append('[');
        sb.append(srcMeth);
        if (add_parens) sb.append("()");
        sb.append(']');
      }
      if (msg == null) {
        if (params != null) {
          sb.append("params: ");
          for (int i = 0, len = params.length; i < len; ++i) {
            if (i != 0) sb.append(", ");
            sb.append(params[i]);
          }
        }
      } else {
        if (params == null) sb.append(msg);
        else {
          MessageFormat mfmt = new MessageFormat(msg);
          sb.append(mfmt.format(params));
        }
      }

      if (t != null) {
        sb.append(SEP);
        sb.append(ThrowableUtils.extractStackTrace(t));
      }

      return sb.toString();
    }
Ejemplo n.º 4
0
 public synchronized boolean isLoggable(MLevel l) {
   return (l.intValue() >= cutoffLevel.intValue());
 }