Monolog Log Handler is using old constructor parameters

Open Beginner friendly
#19,177 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
90/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
documentation

Research direction

Open the PHP Logs page linked in the issue and review the LogsHandler example against the sentry/sentry 4.30 signature. Update the example to use the working constructor form, or clearly identify the SDK version it targets. Done means the documented example matches the supported API and no longer passes a Hub to LogsHandler.

Written by the indexing model from the issue text.

Description

Docs Good First Issue Platform: PHP SDKs
SDK

PHP SDK

Description

Page: https://docs.sentry.io/platforms/php/logs/
SDK version: sentry/sentry 4.30

Problem
The PHP Logs docs show constructing the Monolog logs handler with a Hub (and level) argument

$handler = new \Sentry\Monolog\LogsHandler($hub, Level::Info);

This signature does not exist in sentry/sentry 4.30. LogsHandler does not accept a Hub in its constructor, so following the docs as written fails.

What works instead (4.30)

$log->pushHandler(new \Sentry\Monolog\LogsHandler(Level::Info));

The handler uses the current hub from the initialized SDK; no Hub argument is needed.

Request
Please update the Logs page to match the 4.x LogsHandler signature, or clarify which SDK version the current example targets.

Suggested Solution

$log->pushHandler(new \Sentry\Monolog\LogsHandler(Level::Info));

Dominant language
MDX
Stars
446
Forks
1.7k
Avg merge
1d 21h
Merged PRs (30d)
312

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-docs

All issues in getsentry/sentry-docs

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.