Skip to content

Commit

Permalink
logging cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
othiym23 committed Sep 27, 2014
1 parent 4b2d95d commit c7ab76f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
9 changes: 5 additions & 4 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ cache.add = function (pkg, ver, where, scrub, cb) {
add([pkg, ver], where, cb)
})
}
log.verbose("cache add", [pkg, ver])
return add([pkg, ver], where, cb)
}

Expand All @@ -249,6 +248,8 @@ function add (args, where, cb) {
, spec
, p

log.silly("cache add", "args", args)

if (args[1] === undefined) args[1] = null

// at this point the args length must ==2
Expand All @@ -258,7 +259,7 @@ function add (args, where, cb) {
spec = args[0]
}

log.verbose("cache add", "spec=%j args=%j", spec, args)
log.verbose("cache add", "spec", spec)

if (!spec) return cb(usage)

Expand All @@ -272,7 +273,7 @@ function add (args, where, cb) {
// normalization
p = npa(spec)
if (p.type === "local" && where) spec = path.resolve(where, p.spec)
log.verbose("parsed spec", p)
log.silly("cache add", "parsed spec", p)

// short-circuit local installs
fs.stat(spec, function (er, s) {
Expand All @@ -292,7 +293,7 @@ function addAndLogLocal (spec, cb) {

function addNonLocal (spec, cb) {
var p = npa(spec)
log.verbose("parsed spec", p)
log.silly("addNonLocal", "parsed spec", p)

switch (p.type) {
case "remote":
Expand Down
7 changes: 4 additions & 3 deletions lib/cache/add-named.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function addNamed (name, version, data, cb_) {
assert(typeof name === "string", "must have module name")
assert(typeof cb_ === "function", "must have callback")

log.verbose("addNamed", [name, version])

var key = name + "@" + version
log.verbose("addNamed", key)

function cb (er, data) {
if (data && !data._fromGithub) data._from = key
cb_(er, data)
Expand All @@ -33,7 +33,8 @@ function addNamed (name, version, data, cb_) {

if (!cb_) return

log.verbose("addNamed", [semver.valid(version), semver.validRange(version)])
log.silly("addNamed", "semver.valid", semver.valid(version))
log.silly("addNamed", "semver.validRange", semver.validRange(version))
var fn = ( semver.valid(version, true) ? addNameVersion
: semver.validRange(version, true) ? addNameRange
: addNameTag
Expand Down
8 changes: 3 additions & 5 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,9 @@ function readDependencies (context, where, opts, cb) {
var wrapfile = path.resolve(where, "npm-shrinkwrap.json")

fs.readFile(wrapfile, "utf8", function (er, wrapjson) {
if (er) {
log.verbose("readDependencies", "using package.json deps")
return cb(null, data, null)
}
if (er) return cb(null, data, null)

log.verbose("readDependencies", "npm-shrinkwrap.json is overriding dependencies")
var newwrap
try {
newwrap = JSON.parse(wrapjson)
Expand Down Expand Up @@ -652,7 +650,7 @@ function installMany (what, where, context, cb) {
targets.forEach(function (t) {
newPrev[t.name] = t.version
})
log.silly("resolved", targets)
log.silly("install resolved", targets)
targets.filter(function (t) { return t }).forEach(function (t) {
log.info("install", "%s into %s", t._id, where)
})
Expand Down
5 changes: 3 additions & 2 deletions lib/unbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function unbuild_ (silent) { return function (folder, cb_) {
}
folder = path.resolve(folder)
delete build._didBuild[folder]
log.verbose(folder.substr(npm.prefix.length + 1), "unbuild")
log.verbose("unbuild", folder.substr(npm.prefix.length + 1))
readJson(path.resolve(folder, "package.json"), function (er, pkg) {
// if no json, then just trash it, but no scripts or whatever.
if (er) return gentlyRm(folder, false, cb)
Expand Down Expand Up @@ -53,7 +53,8 @@ function rmStuff (pkg, folder, cb) {

readJson.cache.del(path.resolve(folder, "package.json"))

log.verbose([top, gnm, parent], "unbuild " + pkg._id)
log.verbose("unbuild rmStuff", pkg._id, "from", gnm)
if (!top) log.verbose("unbuild rmStuff", "in", parent)
asyncMap([rmBins, rmMans], function (fn, cb) {
fn(pkg, folder, parent, top, cb)
}, cb)
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ var installLocks = {}
function lockFileName (base, name) {
var c = name.replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "")
, h = crypto.createHash("sha1").update(name).digest("hex")
var generated = "." + h.substr(0, 8) + "-" + c.substr(-32)
log.silly("lockFile", generated, name)
return path.resolve(base, generated + ".lock")

return path.resolve(base, "."+h.substr(0, 8)+"-"+c.substr(-32)+".lock")
}

function lock (base, name, cb) {
Expand All @@ -23,7 +22,7 @@ function lock (base, name, cb) {
, retries: npm.config.get("cache-lock-retries")
, wait: npm.config.get("cache-lock-wait") }
var lf = lockFileName(base, name)
log.verbose("lock", name, lf)
log.verbose("locking", name, "with", lf)
lockfile.lock(lf, opts, function(er) {
if (!er) installLocks[lf] = true
cb(er)
Expand All @@ -38,6 +37,7 @@ function unlock (base, name, cb) {
return process.nextTick(cb)
}
else if (locked === true) {
log.verbose("unlocking", name, "from", lf)
installLocks[lf] = false
lockfile.unlock(lf, cb)
}
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/tar.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function pack_ (tarball, folder, pkg, cb) {


function unpack (tarball, unpackTarget, dMode, fMode, uid, gid, cb) {
log.verbose("tar unpack", tarball)
log.verbose("tar", "unpack", tarball)
log.verbose("tar", "unpacking to", unpackTarget)
if (typeof cb !== "function") cb = gid, gid = null
if (typeof cb !== "function") cb = uid, uid = null
if (typeof cb !== "function") cb = fMode, fMode = npm.modes.file
Expand Down

0 comments on commit c7ab76f

Please sign in to comment.