add more logging options
This commit is contained in:
parent
77ae2cc627
commit
3cc7c812e8
@ -16,6 +16,8 @@ use APnutI\Exceptions\PollAccessRestrictedException;
|
|||||||
use APnutI\Meta;
|
use APnutI\Meta;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Handler\RotatingFileHandler;
|
use Monolog\Handler\RotatingFileHandler;
|
||||||
|
use Monolog\Handler\StreamHandler;
|
||||||
|
use Monolog\Handler\SyslogHandler;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Psr\Log\NullLogger;
|
use Psr\Log\NullLogger;
|
||||||
|
|
||||||
@ -78,7 +80,10 @@ class APnutI
|
|||||||
?string $app_name = null,
|
?string $app_name = null,
|
||||||
?string $redirect_uri = null,
|
?string $redirect_uri = null,
|
||||||
?string $log_path = null,
|
?string $log_path = null,
|
||||||
$log_level = null
|
string|int|null $log_level = null,
|
||||||
|
bool $use_rotating_file_handler = true,
|
||||||
|
bool $use_stream_handler = false,
|
||||||
|
bool $use_syslog_handler = false,
|
||||||
) {
|
) {
|
||||||
if (!empty($app_name)) {
|
if (!empty($app_name)) {
|
||||||
$this->app_name = $app_name;
|
$this->app_name = $app_name;
|
||||||
@ -93,8 +98,18 @@ class APnutI
|
|||||||
: new Logger($this->app_name);
|
: new Logger($this->app_name);
|
||||||
$this->token_session_key = $this->app_name . 'access_token';
|
$this->token_session_key = $this->app_name . 'access_token';
|
||||||
$this->token_redirect_after_auth = $this->app_name . 'redirect_after_auth';
|
$this->token_redirect_after_auth = $this->app_name . 'redirect_after_auth';
|
||||||
|
if ($use_rotating_file_handler) {
|
||||||
$handler = new RotatingFileHandler($log_path, 5, $log_level, true);
|
$handler = new RotatingFileHandler($log_path, 5, $log_level, true);
|
||||||
$this->logger->pushHandler($handler);
|
$this->logger->pushHandler($handler);
|
||||||
|
}
|
||||||
|
if ($use_stream_handler) {
|
||||||
|
$handler = new StreamHandler($log_path, $log_level, true);
|
||||||
|
$this->logger->pushHandler($handler);
|
||||||
|
}
|
||||||
|
if ($use_syslog_handler) {
|
||||||
|
$handler = new SyslogHandler($this->app_name, \LOG_USER, $log_level, true);
|
||||||
|
$this->logger->pushHandler($handler);
|
||||||
|
}
|
||||||
$this->server_token = null;
|
$this->server_token = null;
|
||||||
$this->logger->debug('__construct API');
|
$this->logger->debug('__construct API');
|
||||||
if (isset($_SESSION[$this->token_session_key])) {
|
if (isset($_SESSION[$this->token_session_key])) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user