diff --git a/library/log4php/LoggerLocationInfo.php b/library/log4php/LoggerLocationInfo.php new file mode 100644 --- /dev/null +++ b/library/log4php/LoggerLocationInfo.php @@ -0,0 +1,103 @@ +lineNumber = isset($trace['line']) ? $trace['line'] : null; + $this->fileName = isset($trace['file']) ? $trace['file'] : null; + $this->className = isset($trace['class']) ? $trace['class'] : null; + $this->methodName = isset($trace['function']) ? $trace['function'] : null; + $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . + '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')'; + } + + /** Returns the caller class name. */ + public function getClassName() { + return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className; + } + + /** Returns the caller file name. */ + public function getFileName() { + return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName; + } + + /** Returns the caller line number. */ + public function getLineNumber() { + return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber; + } + + /** Returns the caller method name. */ + public function getMethodName() { + return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName; + } + + /** Returns the full information of the caller. */ + public function getFullInfo() { + return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo; + } + +}