/home/desid573/verdenaturopathy.com.au/wp-content/plugins/duplicator/src/Libs/Snap
Edit: /home/desid573/verdenaturopathy.com.au/wp-content/plugins/duplicator/src/Libs/Snap/SnapLog.php (6236B)
";
$lfp = self::$logFilepath;
// echo "logging $s to {$lfp}
";
if (self::$logFilepath === null) {
throw new Exception('Logging not initialized');
}
if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
$timepart = $_SERVER['REQUEST_TIME_FLOAT'];
} else {
$timepart = $_SERVER['REQUEST_TIME'];
}
$thread_id = sprintf("%08x", abs(crc32($_SERVER['REMOTE_ADDR'] . $timepart . $_SERVER['REMOTE_PORT'])));
$s = $thread_id . ' ' . date('h:i:s') . ":$s";
if (self::$logHandle === null) {
self::$logHandle = fopen(self::$logFilepath, 'a');
}
fwrite(self::$logHandle, "$s\n");
if ($flush) {
fflush(self::$logHandle);
fclose(self::$logHandle);
self::$logHandle = fopen(self::$logFilepath, 'a');
}
}
/**
* Get formatted string fo value
*
* @param mixed $var value to convert to string
* @param bool $checkCallable if true check if var is callable and display it
*
* @return string
*/
public static function v2str($var, $checkCallable = false)
{
if ($checkCallable && is_callable($var)) {
return '(callable) ' . print_r($var, true);
}
switch (gettype($var)) {
case "boolean":
return $var ? 'true' : 'false';
case "integer":
case "double":
return (string) $var;
case "string":
return '"' . $var . '"';
case "array":
case "object":
return print_r($var, true);
case "resource":
case "resource (closed)":
case "NULL":
case "unknown type":
default:
return gettype($var);
}
}
/**
* Get backtrace of calling line
*
* @param string $message message
*
* @return string
*/
public static function getCurrentbacktrace($message = 'getCurrentLineTrace')
{
$callers = debug_backtrace();
array_shift($callers);
$file = $callers[0]['file'];
$line = $callers[0]['line'];
$result = 'BACKTRACE: ' . $message . "\n";
$result .= "\t[" . $file . ':' . $line . "]\n";
$result .= self::traceToString($callers, 1, true);
return $result;
}
/**
* Get trace string
*
* @param mixed[] $callers result of debug_backtrace
* @param int $fromLevel level to start
* @param bool $tab if true apply tab foreach line
*
* @return string
*/
public static function traceToString($callers, $fromLevel = 0, $tab = false)
{
$result = '';
for ($i = $fromLevel; $i < count($callers); $i++) {
$result .= ($tab ? "\t" : '');
$trace = $callers[$i];
if (!empty($trace['class'])) {
$result .= str_pad('TRACE[' . $i . '] CLASS___: ' . $trace['class'] . $trace['type'] . $trace['function'], 45, ' ');
} else {
$result .= str_pad('TRACE[' . $i . '] FUNCTION: ' . $trace['function'], 45, ' ');
}
if (isset($trace['file'])) {
$result .= ' FILE: ' . $trace['file'] . '[' . $trace['line'] . ']';
} else {
$result .= ' NO FILE';
}
$result .= "\n";
}
return $result;
}
/**
* Get exception message file line trace
*
* @param Exception|Error $e exception object
* @param bool $displayMessage if true diplay exception message
*
* @return string
*/
public static function getTextException($e, $displayMessage = true)
{
$result = ($displayMessage ? $e->getMessage() . "\n" : '');
return $result . "FILE:" . $e->getFile() . '[' . $e->getLIne() . "]\n" .
"TRACE:\n" . $e->getTraceAsString();
}
}