Skip to content

[Console] allow the console logging handler to work and prevent propagation only when interactive #58715

Open
symfony/monolog-bundle
#504
@dkarlovi

Description

@dkarlovi

Description

Let's assume this setup

monolog:
    handlers:
        console:
            type: console
            interactive_only: true # this is new
        logstash:
            type: stream
            path: "php://stderr"
            formatter: 'monolog.formatter.logstash'

Now let's assume we're running some command meant for non-interactive use, like messenger:consume, see #57776.

When running the command using logging interactively (user running the command and watching the output) currently, you'll get both the command output, console output and the logstash JSON, which is creating a giant mess of output.

What would be better is to allow the logger to know if there's a user watching the output (command is in an interactive shell or not) and then:

  1. output console and skip logstash (prevent bubble) when interactive
  2. skip console and only output logstash when not interactive

This would mean the logging is adjusted to the current runtime better automatically.

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions