org.x4juli.global.spi.location
Class LocationInfo

java.lang.Object
  extended byorg.x4juli.global.spi.location.LocationInfo
All Implemented Interfaces:
java.io.Serializable

public class LocationInfo
extends java.lang.Object
implements java.io.Serializable

In java.util.logging.LogRecord are line number and source file as information missing. They have to be obtained, which is an expensive operation due to creating a new Throwable.

Logging API as a whole was originally done for Apache log4j. Juli is a port of main parts of that to complete the Java Logging APIs. All credits for initial idea, design, implementation, documentation belong to the log4j crew. This file was originally published by Mathias Rupprecht. Please use exclusively the appropriate mailing lists for questions, remarks and contribution.

Since:
0.5
Author:
Boris Unckel
See Also:
Serialized Form

Field Summary
(package private)  java.lang.String className
          Caller's fully qualified class name.
(package private)  java.lang.String fileName
          Caller's file name.
(package private)  java.lang.String fullInfo
          All available caller information, in the format fully.qualified.classname.of.caller.methodName(Filename.java:line)
(package private)  java.lang.String lineNumber
          Caller's line number.
(package private)  java.lang.String methodName
          Caller's method name.
static LocationInfo NA_LOCATION_INFO
          NA_LOCATION_INFO is used in conjunction with deserialized LogRecords without real location info available.
private static long serialVersionUID
           
 
Constructor Summary
LocationInfo(java.util.logging.LogRecord record)
           
LocationInfo(java.lang.String fileName, java.lang.String className, java.lang.String methodName, java.lang.String lineNumber)
           
LocationInfo(java.lang.Throwable t, java.lang.String fqnOfInvokingClass)
          Instantiate location information based on a Throwable.
 
Method Summary
 boolean equals(java.lang.Object o)
          
 java.lang.String getClassName()
          Return the fully qualified class name of the caller making the logging request.
 java.lang.String getFileName()
          Return the file name of the caller.
 java.lang.String getFullInfo()
          Returns the full info.
 java.lang.String getLineNumber()
          Returns the line number of the caller.
 java.lang.String getMethodName()
          Returns the method name of the caller.
 int hashCode()
          
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

lineNumber

java.lang.String lineNumber
Caller's line number.


fileName

java.lang.String fileName
Caller's file name.


className

java.lang.String className
Caller's fully qualified class name.


methodName

java.lang.String methodName
Caller's method name.


fullInfo

transient java.lang.String fullInfo
All available caller information, in the format fully.qualified.classname.of.caller.methodName(Filename.java:line)


NA_LOCATION_INFO

public static final LocationInfo NA_LOCATION_INFO
NA_LOCATION_INFO is used in conjunction with deserialized LogRecords without real location info available.

Since:
0.5
Constructor Detail

LocationInfo

public LocationInfo(java.lang.String fileName,
                    java.lang.String className,
                    java.lang.String methodName,
                    java.lang.String lineNumber)

LocationInfo

public LocationInfo(java.util.logging.LogRecord record)

LocationInfo

public LocationInfo(java.lang.Throwable t,
                    java.lang.String fqnOfInvokingClass)
Instantiate location information based on a Throwable. We expect the Throwable t, to be in the format



       java.lang.Throwable
       ...
       at org.apache.log4j.PatternLayout.format(PatternLayout.java:413)
       at org.apache.log4j.FileAppender.doAppend(FileAppender.java:183)
       at org.apache.log4j.Category.callAppenders(Category.java:131)
       at org.apache.log4j.Category.log(Category.java:512)
       at callers.fully.qualified.className.methodName(FileName.java:74)
       ...



 

However, we can also deal with JIT compilers that "lose" the location information, especially between the parentheses.

Parameters:
t - the throwable to check.
fqnOfInvokingClass - the full qualified name of the caller. (In Juli varying).
Since:
0.5
Method Detail

equals

public boolean equals(java.lang.Object o)

Since:
0.5

hashCode

public int hashCode()

Since:
0.5

getClassName

public java.lang.String getClassName()
Return the fully qualified class name of the caller making the logging request.

Since:
0.5

getFileName

public java.lang.String getFileName()
Return the file name of the caller.

This information is not always available.

Returns:
file name of the caller.
Since:
0.5

getLineNumber

public java.lang.String getLineNumber()
Returns the line number of the caller.

This information is not always available.

Returns:
line number of the caller.
Since:
0.5

getMethodName

public java.lang.String getMethodName()
Returns the method name of the caller.

Returns:
method name of the caller.
Since:
0.5

getFullInfo

public java.lang.String getFullInfo()
Returns the full info. fullInfo format is: fully.qualified.classname.of.caller.methodName(Filename.java:line)

Returns:
full location info.
Since:
0.5

toString

public java.lang.String toString()

Since:
0.5


${license_html}