diff options
author | isaacs <i@izs.me> | 2012-06-07 01:48:24 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-06-07 01:56:35 +0400 |
commit | 2568e40a395b809fb34125b3383f9f2616004f73 (patch) | |
tree | b770c89d4ed5a46341bf3b42e563a7fbf110af32 /lib/npm.js | |
parent | d4b2d1149a0f2b56467ebeebd36e21d3a2bfe48a (diff) |
Replace the log util with npmlog module
This feels so good. lib/utils/log.js is the worst kind of
glue code that keeps the npm project from being properly
abstracted into independent pieces.
In the process, also cleaned up a lot of unproductive logging,
and made the npm-debug.log generated on errors be a bit more
easy to read.
Diffstat (limited to 'lib/npm.js')
-rw-r--r-- | lib/npm.js | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/npm.js b/lib/npm.js index 2db21e34d..1a7ae4b42 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -18,7 +18,7 @@ var EventEmitter = require("events").EventEmitter , npm = module.exports = new EventEmitter , config = require("./config.js") , ini = require("./utils/ini.js") - , log = require("./utils/log.js") + , log = require("npmlog") , fs = require("graceful-fs") , path = require("path") , abbrev = require("abbrev") @@ -64,17 +64,17 @@ try { npm.version = j.version npm.nodeVersionRequired = j.engines.node if (!semver.satisfies(process.version, j.engines.node)) { - log.error(["" + log.error("unsupported version", ["" ,"npm requires node version: "+j.engines.node ,"And you have: "+process.version ,"which is not satisfactory." ,"" ,"Bad things will likely happen. You have been warned." - ,""].join("\n"), "unsupported version") + ,""].join("\n")) } } catch (ex) { try { - log(ex, "error reading version") + log.info("error reading version", ex) } catch (er) {} npm.version = ex } @@ -250,7 +250,7 @@ npm.load = function (conf, cb_) { } } - log.waitForConfig() + log.pause() load(npm, conf, cb) } @@ -268,6 +268,14 @@ function load (npm, conf, cb) { //console.error("about to look up configs") ini.resolveConfigs(conf, function (er) { + log.level = npm.config.get("loglevel") + log.heading = "npm" + switch (npm.config.get("color")) { + case "always": log.enableColor(); break + case false: log.disableColor(); break + } + log.resume() + //console.error("back from config lookup", er && er.stack) if (er) return cb(er) @@ -352,7 +360,7 @@ function setUser (cl, dc, cb) { var prefix = path.resolve(cl.get("prefix")) mkdir(prefix, function (er) { if (er) { - log.error(prefix, "could not create prefix directory") + log.error("could not create prefix dir", prefix) return cb(er) } fs.stat(prefix, function (er, st) { |