Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat: add slient option #1712

Merged
merged 9 commits into from
Dec 7, 2018
Merged

feat: add slient option #1712

merged 9 commits into from
Dec 7, 2018

Conversation

pkafei
Copy link
Contributor

@pkafei pkafei commented Nov 15, 2018

This PR resolves #1683. This PR is not merge-ready and I wanted to highlight some of the issues I've currently ran into.

node src/cli/bin daemon --silent does not disable printing "Swarming listening on..." and I'm not sure exactly why this option is not picked up by the core library.

Also, when I use print as a property the peer address is printed on a new line. Not sure how to remedy this behavior but I did try using process.stdout.write(). https://stackoverflow.com/questions/6157497/node-js-printing-to-console-without-a-trailing-newline

However when I implemented process.stdout.write() the address came before the print statement process.stdout.write()

Initializing IPFS daemon...
/ip4/127.0.0.1/tcp/4003/ws/ipfs/QmYT3Sv3paCcitjsSbBaeCuXRjcpTs4J87hVPyS4YLiji6Swarm listening on
/ip4/127.0.0.1/tcp/4002/ipfs/QmYT3Sv3paCcitjsSbBaeCuXRjcpTs4J87hVPyS4YLiji6Swarm listening on
/ip4/192.168.1.27/tcp/4002/ipfs/QmYT3Sv3paCcitjsSbBaeCuXRjcpTs4J87hVPyS4YLiji6Swarm listening on
/ip4/10.52.0.22/tcp/4002/ipfs/QmYT3Sv3paCcitjsSbBaeCuXRjcpTs4J87hVPyS4YLiji6Swarm listening on
API listening on /ip4/127.0.0.1/tcp/5002
Gateway (read only) listening on /ip4/127.0.0.1/tcp/9090
Web UI available at http://127.0.0.1:5002/webui

@pkafei pkafei added the status/in-progress In progress label Nov 15, 2018
@pkafei pkafei self-assigned this Nov 15, 2018
@pkafei pkafei requested a review from alanshaw November 15, 2018 09:35
@hugomrdias
Copy link
Member

hi @pkafei CI lint jobs are failing check https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md#commits for commit guidelines and also run npm run lint to check eslint errors.

@pkafei
Copy link
Contributor Author

pkafei commented Nov 15, 2018

@hugomrdias I don't understand the output "Failed to extract deps-macos-10.11.0.tar.gz"- this doesn't seem like it's a JS style error. https://ci.ipfs.team/blue/organizations/jenkins/IPFS%2Fjs-ipfs/detail/ipfs-cli-fun/1/pipeline

@achingbrain
Copy link
Member

achingbrain commented Nov 15, 2018

Failed to extract deps-macos-10.11.0.tar.gz

This is Jenkins running out of disk space on the worker in question. You can tell by opening the full console output for the build and looking for log lines that ran on that worker (e.g. search the output for macos:10.11.0 test:node).

@hugomrdias is right though, the commit lint failed the build in an earlier step though neglected to tell anyone. Thanks Jenkins.

@pkafei
Copy link
Contributor Author

pkafei commented Nov 15, 2018

@achingbrain I suspected this might be a build error. So what are the next steps? Should I ignore the error message or is there something I can do to make this test pass?

@hugomrdias
Copy link
Member

@pkafei first fix code lint errors and commit lint errors

@pkafei
Copy link
Contributor Author

pkafei commented Nov 15, 2018

@hugomrdias @achingbrain Wait, I'm confused- is the lint error based on a JS style issue or is it a build problem. If it is the latter, I'm not sure how to go about fixing the build issue.

@hugomrdias
Copy link
Member

Just ignore this error Failed to extract deps-macos-10.11.0.tar.gz

your commit looks like First attempt at activating silent option in cli and that doesn't comply with our guidelines https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md#commits

also in your computer run npm run lint and you will see errors, please fix these and push again.

src/cli/utils.js Outdated
@@ -47,6 +47,7 @@ exports.getIPFS = (argv, callback) => {
// Required inline to reduce startup time
const IPFS = require('../core')
const node = new IPFS({
print: argv.print,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print: argv.print,
silent: argv.silent,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option name is silent, not print.

@@ -96,7 +96,7 @@ module.exports = function libp2p (self) {
if (err) { return callback(err) }

self._libp2pNode.peerInfo.multiaddrs.forEach((ma) => {
console.log('Swarm listening on', ma.toString())
self._print('Swarm listening on ', console.log(ma.toString()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self._print('Swarm listening on ', console.log(ma.toString()))
self._print('Swarm listening on', ma.toString())

@@ -108,6 +108,8 @@ class IPFS extends EventEmitter {
this._preload = preload(this)
this._mfsPreload = mfsPreload(this)
this._ipns = new IPNS(null, this)
this._print = options.silent ? (() => {}) : ((msg) => console.log(msg))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be a good idea to move printed messages into the debug log if silent=true, so if you specify DEBUG=jsipfs* jsipfs daemon --silent you'll still be able to access that information - what do you think?

Suggested change
this._print = options.silent ? (() => {}) : ((msg) => console.log(msg))
this._print = this._options.silent ? this.log : console.log

Also, we should pass the console.log funciton directly here so that we can log multiple args.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I pass the --silent as an option in the command line I'm still receiving Swarm addresses as output in the terminal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try logging out the value of this._options.silent here and argv.silent in src/cli/utils.js . Maybe it's not being passed in correctly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you figure this out in the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't had a chance to work on this in the past couple of days, but plan on getting back to this this afternoon.

@alanshaw
Copy link
Member

Would you mind rebasing for green CI please?

Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, next steps for this PR are to add a test and document the new option on the README here.

@alanshaw alanshaw mentioned this pull request Nov 29, 2018
package.json Outdated
@@ -167,12 +167,13 @@
"read-pkg-up": "^4.0.0",
"readable-stream": "3.0.6",
"receptacle": "^1.3.2",
"sinon": "^7.1.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the devDependencies block..

Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me, just a couple of tweaks to the documentation and I think we'll be good for merge.

README.md Outdated

| Type | Default |
|------|---------|
| string | `null` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type is Boolean and default is false

README.md Outdated
|------|---------|
| string | `null` |

The silent option prevents swarm info output in the cli and http client.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Prevents all logging output from the IPFS node"

@alanshaw alanshaw changed the title First attempt at activating silent option in cli feat: add slient option Dec 4, 2018
@alanshaw
Copy link
Member

alanshaw commented Dec 7, 2018

@pkafei I took a quick look and resolved the issue with the libp2p tests. Hopefully CI will be 🍏 now.

I've rebased the branch again. 🚢 🚢 🚢

@pkafei
Copy link
Contributor Author

pkafei commented Dec 7, 2018

@alanshaw That's exciting news! It won't be long :shipit:

@alanshaw alanshaw merged commit 593334b into master Dec 7, 2018
@ghost ghost removed the status/in-progress In progress label Dec 7, 2018
@alanshaw alanshaw deleted the logging-bug branch December 7, 2018 18:14
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.

Turn off logger?
4 participants