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

Proposal: Add a logging method to BuildTask #9382

Closed
phptek opened this issue Jan 22, 2020 · 1 comment
Closed

Proposal: Add a logging method to BuildTask #9382

phptek opened this issue Jan 22, 2020 · 1 comment

Comments

@phptek
Copy link

phptek commented Jan 22, 2020

Affected Version

All.

Description

Almost every BuildTask I see and every one I write, there is a need to output some information to the screen in a PHP SAPI specific way. This inevitably means that a developer writes a method similar to the following.

    /**
     *
     * @param string $message
     * @param int $numLines
     */
    public static function out(string $message, int $numLines = 1)
    {
        $newLine = Director::is_cli() ? PHP_EOL : '<br/>';

        echo $message . str_repeat($newLine, $numLines);
    }

There is of course DB::alteration_message() but this is pretty crude, uses repeated message "type" definitions for each SAPI and makes no account of platform ("\n" is hard-coded rather than using an O/S independent marker such as is provided by PHP_EOL) nor does it provide the ability to use a custom LoggerInterface implementation to e.g. colourise the screen o.p. (See LoggerInterface() in silverstripe/assets FileMigrationHelper for yet another way to achieve this).

This proposal therefore seeks the implementation of a flexible method on BuildTask for logging to the screen (But makes no objection if something even more flexible such as logging to a remote F/S is do-able, providing it is no more complicated than restricting the work to o/p only to the screen).

Steps to Reproduce

Write a BuildTask and try really hard not to need to write a method as described above.

@robbieaverill
Copy link
Contributor

Thanks for raising this, closing as a duplicate of #9183

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