Skip to content

LogsHandler should call close() on __desctuct(). #1915

@alexanderschnitzler

Description

@alexanderschnitzler

Problem Statement

All handlers provided by monolog itself extend the abstract class \Monolog\Handler\Handler which has a destructor:

public function __destruct()
{
    try {
        $this->close();
    } catch (\Throwable $e) {
        // do nothing
    }
}

This is in line with the comment on \Monolog\Logger::close() which states:

This is useful at the end of a request and will be called automatically on every handler when they get destructed.

This however is only true for all handler extending the abstract class. The LogsHandler does not which requires a manual call to the close() method to actually send the logs to sentry.

Solution Brainstorm

I think LogsHandler should either check if extending \Monolog\Handler\Handler is possible or of it should replicate it's __destruct() behavior.

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions