Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2010, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 
 package org.jboss.logging;
 
 
 class JBossLogRecord extends LogRecord {
 
     private static final long serialVersionUID = 2492784413065296060L;
     private static final String LOGGER_CLASS_NAME = Logger.class.getName();
 
     private boolean resolved;
     private final String loggerClassName;
 
     JBossLogRecord(final Level levelfinal String msg) {
         super(levelmsg);
          = ;
     }
 
     JBossLogRecord(final Level levelfinal String msgfinal String loggerClassName) {
         super(levelmsg);
         this. = loggerClassName;
     }
 
     public String getSourceClassName() {
         if (! ) {
             resolve();
         }
         return super.getSourceClassName();
     }
 
     public void setSourceClassName(final String sourceClassName) {
          = true;
         super.setSourceClassName(sourceClassName);
     }
 
     public String getSourceMethodName() {
         if (! ) {
             resolve();
         }
         return super.getSourceMethodName();
     }
 
     public void setSourceMethodName(final String sourceMethodName) {
          = true;
         super.setSourceMethodName(sourceMethodName);
     }
 
     private void resolve() {
          = true;
         final StackTraceElement[] stack = new Throwable().getStackTrace();
         boolean found = false;
         for (StackTraceElement element : stack) {
             final String className = element.getClassName();
             if (found) {
                 if (! .equals(className)) {
                     setSourceClassName(className);
                     setSourceMethodName(element.getMethodName());
                     return;
                 }
             } else {
                 found = .equals(className);
             }
         }
         setSourceClassName("<unknown>");
         setSourceMethodName("<unknown>");
     }
 
     protected Object writeReplace() {
         final LogRecord replacement = new LogRecord(getLevel(), getMessage());
         replacement.setResourceBundle(getResourceBundle());
         replacement.setLoggerName(getLoggerName());
         replacement.setMillis(getMillis());
         replacement.setParameters(getParameters());
         replacement.setResourceBundleName(getResourceBundleName());
         replacement.setSequenceNumber(getSequenceNumber());
         replacement.setSourceClassName(getSourceClassName());
         replacement.setSourceMethodName(getSourceMethodName());
        replacement.setThreadID(getThreadID());
        replacement.setThrown(getThrown());
        return replacement;
    }
New to GrepCode? Check out our FAQ X