Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

`logstream` option to replace removed `logfd`

  • Loading branch information...
commit 53c7e2cc802bc083a8e9d72d5b27e2a37fc5c951 1 parent cfb3535
@rvagg rvagg authored isaacs committed
View
12 doc/cli/config.md
@@ -427,6 +427,18 @@ What level of logs to report. On failure, *all* logs are written to
Any logs of a higher level than the setting are shown.
The default is "http", which shows http, warn, and error output.
+### logstream
+
+* Default: process.stderr
+* Type: Stream
+
+This is the stream that is passed to the
+[npmlog](https://github.com/isaacs/npmlog) module at run time.
+
+It cannot be set from the command line, but if you are using npm
+programmatically, you may wish to send logs to somewhere other than
+stderr.
+
### long
* Default: false
View
1  lib/npm.js
@@ -263,6 +263,7 @@ function load (npm, conf, cb) {
ini.resolveConfigs(conf, function (er) {
log.level = npm.config.get("loglevel")
log.heading = "npm"
+ log.stream = npm.config.get("logstream")
switch (npm.config.get("color")) {
case "always": log.enableColor(); break
case false: log.disableColor(); break
View
11 lib/utils/config-defs.js
@@ -28,8 +28,14 @@ function validateSemver (data, k, val) {
data[k] = semver.valid(val)
}
+function validateStream (data, k, val) {
+ if (!(val instanceof Stream)) return false
+ data[k] = val
+}
+
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
nopt.typeDefs.Octal = { type: Octal, validate: validateOctal }
+nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
nopt.invalidHandler = function (k, val, type, data) {
log.warn("invalid config", k + "=" + JSON.stringify(val))
@@ -52,6 +58,9 @@ nopt.invalidHandler = function (k, val, type, data) {
case Number:
log.warn("invalid config", "Must be a numeric value")
break
+ case Stream:
+ log.warn("invalid config", "Must be an instance of the Stream class")
+ break
}
}
@@ -141,6 +150,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
, json: false
, link: false
, loglevel : "http"
+ , logstream : process.stderr
, long : false
, message : "%s"
, "node-version" : process.version
@@ -222,6 +232,7 @@ exports.types =
, json: Boolean
, link: Boolean
, loglevel : ["silent","win","error","warn","http","info","verbose","silly"]
+ , logstream : Stream
, long : Boolean
, message: String
, "node-version" : [null, semver]
View
2  lib/utils/lifecycle.js
@@ -10,6 +10,7 @@ var log = require("npmlog")
, chain = require("slide").chain
, constants = require("constants")
, output = require("./output.js")
+ , Stream = require("stream").Stream
, PATH = "PATH"
// windows calls it's path "Path" usually, but this is not guaranteed.
@@ -260,6 +261,7 @@ function makeEnv (data, prefix, env) {
return
}
var value = ini.get(i)
+ if (value instanceof Stream) return
if (!value) value = ""
else if (typeof value !== "string") value = JSON.stringify(value)
Please sign in to comment.
Something went wrong with that request. Please try again.