Own logger to Sentry, but keep Tracy's bluescreens
- medhi
- Generous Backer | 255
Hi, I would like to create an own logger, which will be logging to Sentry,
but still keeps Tracy bluescreens saved on FTP. So I installed
sentry/sdk
and created this logger:
namespace Loggers;
use Tracy\ILogger;
use Tracy\Logger;
class SentryLogger implements ILogger
{
/**
* @var ILogger
*/
private $parentLogger;
public function __construct($sentryDsn)
{
$this->parentLogger = \Tracy\Debugger::getLogger();
\Sentry\init(['dsn' => $sentryDsn ]);
}
public function log($value, $priority = ILogger::INFO)
{
$this->parentLogger->log($value, $priority);
if ($priority === ILogger::EXCEPTION) {
\Sentry\captureException($value);
}
}
}
Logging to Sentry works fine, but it seems, that using the Tracy's
log
function will cause some kind of recurrence and it ends with
overload of PHP memory limit.
Could you please show me a way, how to implement a very simple logger with keeping Tracy's bluescreens functional?
Thanks.