Skip to content
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

Provide method to add log target, instead of overriding component #3152

Closed
timkelty opened this issue Jul 25, 2018 · 2 comments
Closed

Provide method to add log target, instead of overriding component #3152

timkelty opened this issue Jul 25, 2018 · 2 comments

Comments

@timkelty
Copy link
Contributor

I know I can fully override the log component in config/app.php, but I'm wondering if it might be nice to have a method to simply add a log target.

Alternatively, there could be a method to get the default FileTarget configuration: https://github.com/craftcms/cms/blob/develop/src/config/app.php#L230-L262

Thoughts?

@timkelty
Copy link
Contributor Author

Love it!

@brandonkelly
Copy link
Member

I’ve been meaning to make those dynamic component configs easier to modify, so using this as my excuse to do it.

As of the next release, you will be able to do this from config/app.php:

return [
    'components' => [
        'log' => function() {
            // Use the system's `log` config as a starting point
            $config = craft\helpers\App::logConfig();
            if ($config === null) {
                return null;
            }

            // Make changes
            $config['targets'][] = [
                // new log target config
            ];

            // Instantiate and return the component
            return Craft::createObject($config);
        },

        // ...
    ]
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants