Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,61 +26,61 @@ | |
|
||
|
||
/** | ||
* | ||
* An internal utility class. | ||
* | ||
* @author Alexandre Dorokhine | ||
* @author Ceki Gülcü | ||
*/ | ||
public final class Util { | ||
|
||
private Util() {} | ||
private Util() {} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ceki
Author
Member
|
||
|
||
/** | ||
* In order to call {@link SecurityManager#getClassContext()}, which is a | ||
* protected method, we add this wrapper which allows the method to be visible | ||
* inside this package. | ||
*/ | ||
private static final class ClassContextSecurityManager extends SecurityManager { | ||
protected Class<?>[] getClassContext() { | ||
return super.getClassContext(); | ||
/** | ||
* In order to call {@link SecurityManager#getClassContext()}, which is a | ||
* protected method, we add this wrapper which allows the method to be visible | ||
* inside this package. | ||
*/ | ||
private static final class ClassContextSecurityManager extends SecurityManager { | ||
protected Class<?>[] getClassContext() { | ||
return super.getClassContext(); | ||
} | ||
} | ||
}; | ||
private static final ClassContextSecurityManager SECURITY_MANAGER = | ||
new ClassContextSecurityManager(); | ||
|
||
/** | ||
* Returns the name of the class which called the invoking method. | ||
* @return the name of the class which called the invoking method. | ||
*/ | ||
public static Class<?> getCallingClass() { | ||
Class<?>[] trace = SECURITY_MANAGER.getClassContext(); | ||
String thisClassName = Util.class.getName(); | ||
private static final ClassContextSecurityManager SECURITY_MANAGER = new ClassContextSecurityManager(); | ||
|
||
// Advance until Util is found | ||
int i; | ||
for (i = 0 ; i < trace.length ; i++) { | ||
if (thisClassName.equals(trace[i].getName())) | ||
break; | ||
} | ||
/** | ||
* Returns the name of the class which called the invoking method. | ||
* | ||
* @return the name of the class which called the invoking method. | ||
*/ | ||
public static Class<?> getCallingClass() { | ||
Class<?>[] trace = SECURITY_MANAGER.getClassContext(); | ||
String thisClassName = Util.class.getName(); | ||
|
||
// Advance until Util is found | ||
int i; | ||
for(i = 0; i < trace.length; i++) { | ||
if(thisClassName.equals(trace[i].getName())) | ||
break; | ||
} | ||
|
||
// trace[i] = Util; trace[i+1] = caller; trace[i+2] = caller's caller | ||
if (i >= trace.length || i + 2 >= trace.length) { | ||
throw new IllegalStateException( | ||
"Failed to find org.slf4j.helpers.Util or its caller in the stack; " + | ||
"this should not happen"); | ||
// trace[i] = Util; trace[i+1] = caller; trace[i+2] = caller's caller | ||
if(i >= trace.length || i + 2 >= trace.length) { | ||
throw new IllegalStateException( | ||
"Failed to find org.slf4j.helpers.Util or its caller in the stack; " + | ||
"this should not happen"); | ||
} | ||
|
||
return trace[i + 2]; | ||
} | ||
|
||
return trace[i+2]; | ||
} | ||
static final public void report(String msg, Throwable t) { | ||
System.err.println(msg); | ||
System.err.println("Reported exception:"); | ||
t.printStackTrace(); | ||
} | ||
|
||
static final public void report(String msg, Throwable t) { | ||
System.err.println(msg); | ||
System.err.println("Reported exception:"); | ||
t.printStackTrace(); | ||
} | ||
|
||
static final public void report(String msg) { | ||
System.err.println("SLF4J: " +msg); | ||
} | ||
static final public void report(String msg) { | ||
System.err.println("SLF4J: " + msg); | ||
} | ||
} |
Can you clarify what the code style is for slf4j? The LoggerFactory, for instance, seems to use two spaces for indentation.