Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev #195

Merged
merged 1 commit into from
Oct 31, 2024
Merged

dev #195

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Core/CoreException.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ public function capture_errors(bool $turn_warning_to_errors = false) : void
exception: $exception,
);
});

define('LAST_LINE_DEFENCE', E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR);

register_shutdown_function(function () {

$error = error_get_last();


if(!empty($error) && ($error['type'] & LAST_LINE_DEFENCE)) {
self::log_always();

$this->use_exception(
"ShutdownError",
$error['message'] . PHP_EOL
. "File: " . $error['file'] . ":" . $error['line'] . PHP_EOL,
raw: ["err_code" => $error['type']]
);
}
});
}

public function get_env(): string
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public static function always_log() : void
self::new()->log_always();
}

public static function log(mixed $message, Throwable $exception = null) : void
public static function log(mixed $message, Throwable $exception = null, string $log_title = "") : void
{
self::always_log();
self::throw_exception(var_export($message, true), "ManualLog", kill: false, exception: $exception, throw_500: false, echo_error: false);
self::throw_exception(var_export($message, true), "ManualLog:$log_title", kill: false, exception: $exception, throw_500: false, echo_error: false);
}

/**
Expand Down