From b9542217f88ff8fcb2a1fecfb752e0bb8429b1d8 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@keylocation.sg> Date: Tue, 20 Jun 2017 08:02:17 +0200 Subject: [PATCH] Remove log-level verbose (#324) Closes #318 --- lib/api/gitlab.js | 2 +- lib/config/file.js | 2 +- lib/config/index.js | 6 ++---- lib/helpers/changelog.js | 2 +- lib/helpers/github-app.js | 2 +- lib/helpers/versions.js | 4 ++-- lib/index.js | 1 + lib/worker.js | 34 ++++++++++++++++++++++++++-------- lib/workers/branch.js | 24 ++++++++++++------------ lib/workers/pr.js | 10 +++++----- 10 files changed, 52 insertions(+), 35 deletions(-) diff --git a/lib/api/gitlab.js b/lib/api/gitlab.js index 6752562ff1..adb57dd66b 100644 --- a/lib/api/gitlab.js +++ b/lib/api/gitlab.js @@ -89,7 +89,7 @@ async function initRepo(repoName, token, endpoint) { // Returns an array of file paths in current repo matching the fileName async function findFilePaths(fileName) { - logger.verbose("Can't find multiple package.json files in GitLab"); + logger.debug("Can't find multiple package.json files in GitLab"); return [fileName]; } diff --git a/lib/config/file.js b/lib/config/file.js index 56c608effc..c811d19900 100644 --- a/lib/config/file.js +++ b/lib/config/file.js @@ -16,7 +16,7 @@ function getConfig(env) { config = require(configFile); } catch (err) { // Do nothing - logger.verbose('Could not locate config file'); + logger.debug('Could not locate config file'); } return config; } diff --git a/lib/config/index.js b/lib/config/index.js index 38bd31ac6a..f80174eb36 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -61,9 +61,7 @@ async function parseConfigs(env, argv) { throw new Error('A GitHub App Private Key must be provided'); } config.repositories = await githubAppHelper.getRepositories(config); - logger.verbose( - `Found ${config.repositories.length} repositories installed` - ); + logger.info(`Found ${config.repositories.length} repositories installed`); delete config.githubAppKey; logger.debug(`GitHub App config: ${JSON.stringify(config)}`); } else if (config.autodiscover) { @@ -123,7 +121,7 @@ async function parseConfigs(env, argv) { }); // Print config - logger.verbose(`config=${redact(config)}`); + logger.debug(`config=${redact(config)}`); } function getCascadedConfig(repo, packageFile) { diff --git a/lib/helpers/changelog.js b/lib/helpers/changelog.js index f8ab2f1800..ef61a821cd 100644 --- a/lib/helpers/changelog.js +++ b/lib/helpers/changelog.js @@ -17,7 +17,7 @@ async function getChangeLogJSON(depName, fromVersion, newVersion) { try { return await changelog.generate(depName, semverString); } catch (err) { - logger.verbose(`getChangeLogJSON error: ${JSON.stringify(err)}`); + logger.warn(`getChangeLogJSON error: ${JSON.stringify(err)}`); return null; } } diff --git a/lib/helpers/github-app.js b/lib/helpers/github-app.js index 92d0b5b99d..d005b8eafe 100644 --- a/lib/helpers/github-app.js +++ b/lib/helpers/github-app.js @@ -46,7 +46,7 @@ async function getRepositories(config) { config.githubAppKey ); const installations = await ghApi.getInstallations(appToken); - logger.verbose(`Found installations for ${installations.length} users`); + logger.info(`Found installations for ${installations.length} users`); for (const installation of installations) { logger.debug(JSON.stringify(installation)); const installationRepos = await module.exports.getUserRepositories( diff --git a/lib/helpers/versions.js b/lib/helpers/versions.js index c4f5481e95..50b7a60ee7 100644 --- a/lib/helpers/versions.js +++ b/lib/helpers/versions.js @@ -14,12 +14,12 @@ module.exports = { function determineUpgrades(dep, currentVersion, config) { if (!isValidVersion(currentVersion)) { - logger.verbose(`${dep.name} currentVersion is invalid`); + logger.warn(`${dep.name} currentVersion ${currentVersion} is invalid`); return []; } const versions = dep.versions; if (!versions || Object.keys(versions).length === 0) { - logger.verbose(`${dep.name} - no versions`); + logger.warn(`${dep.name} - no versions`); return []; } const versionList = Object.keys(versions); diff --git a/lib/index.js b/lib/index.js index 5ff6f4899a..5d2f252250 100644 --- a/lib/index.js +++ b/lib/index.js @@ -35,6 +35,7 @@ async function start() { // Queue package files in sequence within a repo async function processRepo(repo) { + logger.info(`Processing repository ${repo.repository}`); // Take a copy of the config, as we will modify it const config = Object.assign({}, repo); if (config.platform === 'github') { diff --git a/lib/worker.js b/lib/worker.js index 0745ba980a..eafed0f307 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -25,12 +25,12 @@ async function processPackageFile(repoName, packageFile, packageConfig) { config = Object.assign({}, packageConfig); config.packageFile = packageFile; - logger.info(`Processing ${repoName} ${packageFile}`); + logger.info(`Processing package file ${repoName}:${packageFile}`); const packageContent = await config.api.getFileJson(packageFile); if (!packageContent) { - logger.verbose('No package.json content found - skipping'); + logger.warn('No package.json content found - skipping'); return []; } @@ -78,6 +78,7 @@ async function processPackageFile(repoName, packageFile, packageConfig) { upgrade.prBody = upgrade.yarnMaintenancePrBody; upgrades.push(upgrade); } + logger.info('Finished processing package file'); return upgrades; } @@ -158,12 +159,19 @@ async function findUpgrades(dependencies) { dep.config ); if (upgrades.length > 0) { - logger.verbose(`${dep.depName}: Upgrades = ${JSON.stringify(upgrades)}`); + const upgradeCount = upgrades.length === 1 + ? '1 upgrade' + : `${upgrades.length} upgrades`; + logger.info( + `Dependency ${dep.depName} has ${upgradeCount} available: ${upgrades.map( + upgrade => upgrade.newVersion + )}` + ); upgrades.forEach(upgrade => { allUpgrades.push(Object.assign({}, dep, upgrade)); }); } else { - logger.verbose(`${dep.depName}: No upgrades required`); + logger.debug(`${dep.depName}: No upgrades required`); } } const promiseArray = dependencies.map(dep => findDepUpgrades(dep)); @@ -175,9 +183,12 @@ async function findUpgrades(dependencies) { async function processUpgrades(upgrades) { if (upgrades.length) { - logger.verbose('Processing upgrades'); + const upgradeCount = upgrades.length === 1 + ? '1 dependency upgrade' + : `${upgrades.length} dependency upgrades`; + logger.info(`Processing ${upgradeCount}`); } else { - logger.verbose('No upgrades to process'); + logger.info('No upgrades to process'); } logger.debug(`All upgrades: ${JSON.stringify(upgrades)}`); const branchUpgrades = {}; @@ -245,7 +256,14 @@ async function updateBranch(upgrades) { const branchName = handlebars.compile(upgrade0.branchName)(upgrade0); const prTitle = handlebars.compile(upgrade0.prTitle)(upgrade0); - logger.verbose(`branchName '${branchName}' length is ${upgrades.length}`); + const upgradeCount = upgrades.length === 1 + ? '1 upgrade' + : `${upgrades.length} upgrades`; + logger.info( + `Branch '${branchName}' has ${upgradeCount}: ${upgrades.map( + upgrade => upgrade.depName + )}` + ); try { if ( @@ -254,7 +272,7 @@ async function updateBranch(upgrades) { !upgrade0.recreateClosed && (await upgrade0.api.checkForClosedPr(branchName, prTitle)) ) { - logger.verbose( + logger.info( `Skipping ${branchName} upgrade as matching closed PR already existed` ); return; diff --git a/lib/workers/branch.js b/lib/workers/branch.js index 7f4b1e1e5f..c34349f8a8 100644 --- a/lib/workers/branch.js +++ b/lib/workers/branch.js @@ -12,18 +12,18 @@ module.exports = { async function getParentBranch(branchName, config) { // Check if branch exists if ((await config.api.branchExists(branchName)) === false) { - logger.verbose(`Creating new branch ${branchName}`); + logger.info(`Branch ${branchName} needs creating`); return undefined; } - logger.debug(`${branchName} already exists`); + logger.info(`Branch ${branchName} already exists`); // Check if needs rebasing if ( - (config.automergeEnabled && config.automergeType === 'branch-push') || - config.rebaseStalePrs + config.rebaseStalePrs || + (config.automergeEnabled && config.automergeType === 'branch-push') ) { const isBranchStale = await config.api.isBranchStale(branchName); if (isBranchStale) { - logger.debug(`Branch ${branchName} is stale and needs rebasing`); + logger.info(`Branch ${branchName} is stale and needs rebasing`); return undefined; } } @@ -41,13 +41,13 @@ async function getParentBranch(branchName, config) { if (pr.canRebase) { // Only supported by GitHub // Setting parentBranch back to undefined means that we'll use the default branch - logger.debug(`Rebasing branch ${branchName}`); + logger.debug(`Branch ${branchName} is not mergeable and needs rebasing`); return undefined; } // Don't do anything different, but warn - logger.verbose(`Cannot rebase branch ${branchName}`); + logger.warn(`Branch ${branchName} is not mergeable but can't be rebased`); } - logger.debug(`Existing ${branchName} does not need rebasing`); + logger.debug(`Branch ${branchName} does not need rebasing`); return branchName; } @@ -105,7 +105,7 @@ async function ensureBranch(upgrades) { } } if (Object.keys(packageFiles).length > 0) { - logger.debug( + logger.info( `${Object.keys(packageFiles).length} package file(s) need updating.` ); for (const packageFile of Object.keys(packageFiles)) { @@ -123,7 +123,7 @@ async function ensureBranch(upgrades) { ); if (yarnLockFile) { // Add new yarn.lock file too - logger.debug(`Adding ${yarnLockFile.name}`); + logger.info(`Adding ${yarnLockFile.name}`); commitFiles.push(yarnLockFile); } } catch (err) { @@ -138,12 +138,12 @@ async function ensureBranch(upgrades) { ); if (packageLockFile) { // Add new package-lock.json file too - logger.debug(`Adding ${packageLockFile.name}`); + logger.info(`Adding ${packageLockFile.name}`); commitFiles.push(packageLockFile); } } catch (err) { // This will include if npm < 5 - logger.verbose(err); + logger.debug(err); throw new Error('Could not generate new package-lock.json file'); } } diff --git a/lib/workers/pr.js b/lib/workers/pr.js index 9543d1e74b..79db40482b 100644 --- a/lib/workers/pr.js +++ b/lib/workers/pr.js @@ -106,7 +106,7 @@ async function ensurePr(upgrades) { if (existingPr) { // Check if existing PR needs updating if (existingPr.title === prTitle && existingPr.body === prBody) { - logger.verbose(`${existingPr.displayNumber} already up-to-date`); + logger.info(`${existingPr.displayNumber} does not need updating`); return existingPr; } // PR must need updating @@ -143,24 +143,24 @@ async function ensurePr(upgrades) { async function checkAutoMerge(pr, config) { logger.debug(`Checking #${pr.number} for automerge`); if (config.automergeEnabled && config.automergeType === 'pr') { - logger.verbose('PR is configured for automerge'); + logger.info('PR is configured for automerge'); logger.debug(JSON.stringify(pr)); // Return if PR not ready for automerge if (pr.mergeable !== true || pr.mergeable_state === 'unstable') { - logger.verbose('PR is not ready for merge'); + logger.info('PR is not ready for merge'); return; } // Check branch status const branchStatus = await config.api.getBranchStatus(pr.head.ref); logger.debug(`branchStatus=${branchStatus}`); if (branchStatus !== 'success') { - logger.verbose('Branch status is not "success"'); + logger.info('Branch status is not "success"'); return; } // Let's merge this logger.info(`Automerging #${pr.number}`); await config.api.mergePr(pr); } else { - logger.verbose('No automerge'); + logger.debug('No automerge'); } } -- GitLab