teambition / gulp-ssh

SSH and SFTP tasks for gulp
184 stars 38 forks source link

Allow logging to be tuned #92

Open mojavelinux opened 6 years ago

mojavelinux commented 6 years ago

This library can be used in an application based on vinyl streams, outside of the context of Gulp (see below). In this context, the logging is a nuisance. Allow the logging to be tuned either globally or via the constructor (whichever makes more sense). If this is just a matter of documentation, simply add instructions to the README that explain how to control and tune the logging.

const GulpSSH = require('gulp-ssh')
const vfs = require('vinyl-fs')

;(async () => {
  const gulpSSH = new GulpSSH({
    ignoreErrors: false,
    sshConfig: { username: process.env.USER, agent: process.env.SSH_AUTH_SOCK }
  })
  await new Promise((resolve, reject) => {
    vfs
      .src('*.zip')
      .pipe(gulpSSH.dest('/tmp'))
      .on('error', reject)
      .on('finish', resolve)
  })
})()
dvsoukup commented 6 years ago

+1

I agree. I like gulpssh, but the logging is a hassle. I'd like to suppress much of it, especially when copying files over .dest()

I poked through the source and it looks like it uses npm fancy-log. Most of these various classes (ie, exec, dest, ssh...) allow for an options parameters.

Someone just needs to open a pull request and create this logging option. Doesn't seem like it would be all that difficult. One option to globally shutdown all gulpssh log output, and also you can individually passing logging in to each utility function.. something like:

 return gulp.src(deployFiles)
    .pipe(gssh.dest(config.remoteSettings.destination, {showOutput: false}));

Alternatively, could do it a bit more complicated and allow to set logging levels.