Js-ipfs: Migrate CLI output to Logger

Created on 15 Sep 2016  路  14Comments  路  Source: ipfs/js-ipfs

With the new files APIs, I've started on a logger that has many benefits compared to the current approach of using console.log for output.

  • Intent is clear, console.log is often used to debugging, may not be clear it's actual output from CLI
  • Easier to turn on/off if we want to add a --quiet flag that only outputs some things
  • Abstract away the logging from the CLI itself
  • Easier to build things that continues on the same line, commands that takes time to execute.

I don't think this is a urgent refactor we have to do right now, but maybe we can start thinking about it a little, and write new code with the logger, rather than migrating everything at once.

dieasy help wanted

All 14 comments

馃憤 for having the ability to turn on/off.

Since we use debug for dev logs (log and log.err), let's call the 'logger' that prints info to the user some other thing. Maybe 'printer'?

printer sounds good, and the method should be called print :)

or maybe different methods, like info, error to log messages of corresponding type.

@dignifiedquire agree that it should just be print, probably no need for many functions, just one called print and that would be about it.

@tarunbatra this is about printing output to the console and not logging things that can be controlled by for example log-level and such.

@tarunbatra for log messages we use debug

@diasdavid @VictorBjelkholm thanx for clarifying! I was thinking otherwise.

@VictorBjelkholm could you finish this since you got it started? :)

@diasdavid I just started using it lightly. I think we shouldn't migrate everything at once but rather think about it when writing new/refactoring code (and when reviewing) so at one point, we'll be using it 100%. Does that make sense for you?

Not really, it will confuse contributors and even ourselves at times as it will be always half done.

@diasdavid hm, ok. Will have to push this forward then, won't have any bandwidth currently to work on it...

Hi, I might take a look at this,
as an entry point to get to know
the js-ipfs source code.

Feel free to assign it to me ;)

@rasmuserik thank you! Let me know if you get questions along the way

Can this be closed now, or is anything else missing, after merge of #931 ?

You have completed this! Thanks @rasmuserik 馃挅馃嵕

Was this page helpful?
0 / 5 - 0 ratings