Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Make npm-debug.log path configurable.#5252

Closed
timoxley wants to merge 1 commit intonpm:masterfrom
timoxley:feature/configure-npm-debug-log
Closed

Make npm-debug.log path configurable.#5252
timoxley wants to merge 1 commit intonpm:masterfrom
timoxley:feature/configure-npm-debug-log

Conversation

@timoxley
Copy link
Copy Markdown
Contributor

If this is acceptable, I'll send the appropriate PRs for the npm-log config in npmconf and add docs.

Allows for location of npm-debug.log to be specified:

> npm install asdasdas --log-file=/var/log/npm/myapp.log
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm ERR! 404 404 Not Found: asdasdas
npm ERR! 404
npm ERR! 404 'asdasdas' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 It was specified as a dependency of 'npm-debug-log-test'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

npm ERR! System Darwin 13.2.0
npm ERR! command "node" "/Users/timoxley/Projects/libs/npm/bin/npm-cli.js" "install" "asdasdas" "--log-file=/var/log/npm/myapp.log"
npm ERR! cwd /Users/timoxley/Projects/libs/npm/test/tap/npm-debug-log
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.4.10
npm ERR! code E404
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /var/log/npm/myapp.log
npm ERR! not ok code 0
> ls /var/log/npm
myapp.log

Possible Improvements

  • a mkdirp on the log directory
  • if specify an existing directory, default to writing npm-debug.log in that directory.
  • alias/rename to logfile vs log-file
  • fallback if it can't write to log just write to default process.cwd()/npm-debug.log

Related #1548

@timoxley
Copy link
Copy Markdown
Contributor Author

Note: travis is only failing because I haven't added log-file to npmconf/docs, as mentioned above.

@isaacs
Copy link
Copy Markdown
Contributor

isaacs commented May 11, 2014

Rather than making the location configurable, it should be a specific location that npm knows.

The reason it dumps into CWD today is that the user is there, and knows how to find it. However, once we add npm report to report bugs, it won't really matter. The debug log will just be a thing we can put into tmp or cache or wherever, since the user won't ever have to touch it.

@timoxley
Copy link
Copy Markdown
Contributor Author

Oh, hm.

Perhaps doesn't make this entirely redundant though, once npm report is ready then just set the default log location to tmp or cache or wherever. The location that npm knows is config.get('log-file'). This adds additional flexibility for advanced users who want it. Probably should strive to have as few hard-coded locations as possible – it's particularly frustrating when you need to change something but it's not possible because the author didn't envisage your particular use-case. Saying that though, once npm report lands I can't imagine any particularly compelling use-cases for a configurable debug log. I guess just +1 for making npm more hackable.

I don't feel strongly about this though, feel free to close.

@isaacs
Copy link
Copy Markdown
Contributor

isaacs commented May 12, 2014

If anything, npm is overly configurable, imo. There isn't much value in being able to set the specific filename, when you can already set the cache path, tmp path, prefix, etc. If we just say "it goes in one of those things", then that's fine. I mean, we don't make the path within the cache folder configurable, for example, or let lock filenames be configurable, etc.

isaacs added a commit that referenced this pull request Sep 13, 2014
This should prevent mishaps like #1548, while avoiding overly
configurable options that make it hard to predict where the file
will show up.

Fix #1584
Close #5252
isaacs added a commit that referenced this pull request Sep 26, 2014
This should prevent mishaps like #1548, while avoiding overly
configurable options that make it hard to predict where the file
will show up.

Fix #1584
Close #5252
isaacs added a commit that referenced this pull request Nov 20, 2014
This should prevent mishaps like #1548, while avoiding overly
configurable options that make it hard to predict where the file
will show up.

Fix #1584
Close #5252
smikes pushed a commit to smikes/npm that referenced this pull request Nov 22, 2014
This should prevent mishaps like npm#1548, while avoiding overly
configurable options that make it hard to predict where the file
will show up.

Fix npm#1584
Close npm#5252

update test for new behavior

smikes:
 * strawman version of multiple logs
 * add unit tests for prune, findlogs
@othiym23
Copy link
Copy Markdown
Contributor

I'm going to close this in favor of #6744, which will in turn probably end up getting closed in favor of the ring-buffer cache of recent debug logs that the npm team have been discussing internally for the last year or so. Thanks for putting this together and getting the ball rolling, Tim, and I'm sorry we let this sit around for so long.

@othiym23 othiym23 closed this Feb 27, 2015
kenany pushed a commit to kenany/npm that referenced this pull request Oct 19, 2016
This should prevent mishaps like npm#1548, while avoiding overly
configurable options that make it hard to predict where the file
will show up.

Fix npm#1584
Close npm#5252
iarna pushed a commit that referenced this pull request Jan 24, 2017
We also are storing a configurable number of previous log files.

PR-URL: #11439
Fixes: #5252
Fixes: #6350
Fixes: #1548
Fixes: #7614

Credit: @kenany
Credit: @othiym23
Credit: @isaacs
Credit: @iarna
@AngelicaPerduta
Copy link
Copy Markdown

my npm error log just scrolls off the dos window and I can find no .log file on my hard drive. How can one be expected to work out how to change that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants