New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Allow predefined log channels to change formatter from config #26895

Merged
merged 2 commits into from Dec 19, 2018

Conversation

Projects
None yet
2 participants
@troccoli
Copy link
Contributor

troccoli commented Dec 18, 2018

This PR is about the ability to specify a formatter from the config file for the single, daily and syslog driver.

The default formatter, the LineFormatter, print the date and time, channel name, level and text for every message logged. To change the format of the message, for example to remove the channel name, or to use a different formatter, for example the HtmlFormatter, you have to use the monolog driver with the correct handler.

Compare the following configurations:

return [
    "channels" => [
        "formatted_single" => [
            "driver" => "monolog",
            "handler" => StreamHandler::class
            "handler_with" => [
                "stream" => storage_path("logs/laravel.log"),
                "level" => "info",
            ],
            "formatter" => LineFormatter::class,
            "formatter_with" => [
                "format" => "[%datetime%] %level_name%: %message%",
            ],
        ]
    ]
]

and

return [
    "channels" => [
        "formatted_single" => [
            "driver" => "single",
            "path" => storage_path("logs/laravel.log"),
            "level" => "info",
            "formatter" => LineFormatter::class,
            "formatter_with" => [
                "format" => "[%datetime%] %level_name%: %message%",
            ],
        ]
    ]
]

@troccoli troccoli force-pushed the troccoli:allow-predefined-log-channels-to-change-formatter-from-config branch from 3cb2721 to f2fe2de Dec 19, 2018

Giulio Troccoli-Allard

@troccoli troccoli force-pushed the troccoli:allow-predefined-log-channels-to-change-formatter-from-config branch from f2fe2de to 4e49e7d Dec 19, 2018

@taylorotwell taylorotwell merged commit b714370 into laravel:5.7 Dec 19, 2018

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@troccoli troccoli deleted the troccoli:allow-predefined-log-channels-to-change-formatter-from-config branch Dec 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment