Package com.log4rich.util
Class LocationInfo
java.lang.Object
com.log4rich.util.LocationInfo
Captures location information about where a log event occurred.
This includes class name, method name, line number, and filename.
-
Constructor Summary
ConstructorsConstructorDescriptionLocationInfo
(String className, String methodName, String fileName, int lineNumber) Creates a new LocationInfo with the specified location details. -
Method Summary
Modifier and TypeMethodDescriptionstatic LocationInfo
getCaller
(int skipFrames) Create LocationInfo by analyzing the current stack trace.Gets the simple class name (without package).Gets the source file name.Gets the fully qualified class name.int
Gets the line number where the log event occurred.Gets the method name where the log event occurred.Get truncated class name (e.g., c.e.MyClass).toString()
Returns a string representation of the location information.
-
Constructor Details
-
LocationInfo
Creates a new LocationInfo with the specified location details.- Parameters:
className
- the fully qualified class namemethodName
- the method namefileName
- the source file namelineNumber
- the line number in the source file
-
-
Method Details
-
getCaller
Create LocationInfo by analyzing the current stack trace.- Parameters:
skipFrames
- Number of stack frames to skip (typically 2-3 for logger calls)- Returns:
- LocationInfo object or null if unable to determine
-
getTruncatedClassName
Get truncated class name (e.g., c.e.MyClass).- Returns:
- Truncated class name
-
getClassName
Gets the simple class name (without package).- Returns:
- the simple class name
-
getFullClassName
Gets the fully qualified class name.- Returns:
- the full class name including package
-
getMethodName
Gets the method name where the log event occurred.- Returns:
- the method name
-
getFileName
Gets the source file name.- Returns:
- the source file name
-
getLineNumber
public int getLineNumber()Gets the line number where the log event occurred.- Returns:
- the line number
-
toString
Returns a string representation of the location information.
-