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

Logging mixed up with asynchronous tasks #361

Closed
yocontra opened this issue Mar 20, 2014 · 10 comments
Closed

Logging mixed up with asynchronous tasks #361

yocontra opened this issue Mar 20, 2014 · 10 comments

Comments

@yocontra
Copy link
Member

3rd party modules that log progressively/asynchronously will get stuff mixed in from other tasks

sample

This will have to be fixed at the plugin level or we could do some trickery at the task level

@ClaudioAlbertin
Copy link

I'd like to see gulp itself handling this. It would mean that it automatically works for all plugins and that it could do it in a clean, consistent and configurable manner.

Another argument for this is that many plugins are only very thin wrappers for other libraries, and that handling this themselves would make them unnecessarily more complex, and in this case the wrapped libraries themselves are responsible for logging to the console, the plugin can't do more about it than gulp itself could.

I haven't really looked into possible solutions yet, but the first thing that comes to my mind is replacing the methods of interest from console with custom implementations, admittedly not a very clean approach. If some plugins used this method however, their workarounds for this problem might interfere and cause more problems than they solve.

Libraries such as mocha execute a task that can take anything from a fraction of a second to a couple of minutes or even hours to complete. In the case of mocha, it makes a lot of sense to log its status continuously.
Other libraries such as jshint often don't require continuous logging, and it might be better suited to output their logs all at once, while no other tasks are logging.
A third possible option could be that the logs aren't of any interest at all. Although that might rarely be the case, I'd still suggest having this as an option.
The options are continuous logging, serial logging and no logging, which should be possible to be set at least on a task, maybe even on a .pipe() level.

However, this solution introduces a lot of complexity for a more or less simple problem. I'm not sure if it's worth it, although I don't consider wanting to have clean logs to be an edge case. Having a simple way of running tasks serially might not be the ideal solution for this specific issue, but a simpler and more generally applicable one than introducing a complex and confusing system to configure logging behaviour.

@mgcrea
Copy link

mgcrea commented Apr 4, 2014

Not sure if this is strictly related (looks like it), but in my case it looks like gulp.log is having an issue. Every log is fired right away, and the global task logs should wrap others imo.

gulp.task('build', ['clean:dist', 'templates:dist', 'scripts:dist']);
$ time gulp build
[gulp] Using gulpfile /Users/olivier/Dropbox/Projects/angular-strap/gulpfile.js
[gulp] Starting 'clean:dist'...
[gulp] Finished 'clean:dist' after 4.25 ms
[gulp] Starting 'templates:dist'...
[gulp] Finished 'templates:dist' after 7.1 ms
[gulp] Starting 'scripts:dist'...
[gulp] Finished 'scripts:dist' after 2.34 ms
[gulp] Starting 'build'...
[gulp] Finished 'build' after 4.77 μs

real    0m5.041s
user    0m4.915s
sys 0m0.173s

I'm expecting it to be something like:

$ time gulp build
[gulp] Using gulpfile /Users/olivier/Dropbox/Projects/angular-strap/gulpfile.js
[gulp] Starting 'build'...
[gulp] Starting 'clean:dist'...
[gulp] Starting 'templates:dist'...
[gulp] Starting 'scripts:dist'...
[gulp] Finished 'clean:dist' after 4.25 ms
[gulp] Finished 'templates:dist' after 2.1 s
[gulp] Finished 'scripts:dist' after 2.34 s
[gulp] Finished 'build' after 5.041s

real    0m5.041s
user    0m4.915s
sys 0m0.173s

@chall8908
Copy link

I wouldn't have expected the second log at all. It implies that the other tasks were started after the task you ran started, which isn't the case at all.

To be clear, when I say "started" I mean that the function you passed in has begun executing. I would expect an output like the second if you manually call other tasks within a single task.

@yocontra
Copy link
Member Author

yocontra commented Apr 4, 2014

Just to keep everyone updated, we are completely replacing the logging and task system in gulp 4.0 so we will make sure this is fixed then

@yocontra yocontra added the bug label Sep 1, 2014
@alexewerlof alexewerlof mentioned this issue May 14, 2015
@phated phated added this to the gulp 4 milestone Aug 21, 2015
@phated phated added the gulp4 label Aug 21, 2015
@phated
Copy link
Member

phated commented Aug 21, 2015

Note: this will only be handled when logging is done through gulp-util.log (soon to be gulplog)

@phated
Copy link
Member

phated commented Aug 21, 2015

Ref #1208

@kahlil
Copy link

kahlil commented Sep 15, 2015

Since new logging is done, how does this issue need to be addressed?

@phated
Copy link
Member

phated commented Sep 30, 2015

@kahlil I'm not sure how this would be tackled. Any ideas?

@phated phated added gulp-cli and removed gulp4 labels Nov 19, 2015
@phated phated modified the milestones: gulp-cli 1.1.0, gulp 4 Nov 19, 2015
@phated
Copy link
Member

phated commented Dec 21, 2015

Deferring to gulp-cli 1.2.0

@phated
Copy link
Member

phated commented Apr 5, 2016

Moved to gulpjs/gulp-cli#72 - Closing.

@phated phated closed this as completed Apr 5, 2016
@phated phated removed this from the gulp-cli 1.3.0 milestone Apr 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants