Saturate / HelixForge

Use HelixForge to build your Helix Solutions. (Also all other solutions, because why not!)
MIT License
0 stars 0 forks source link

Logging for tasks and modules #12

Open Saturate opened 7 years ago

Saturate commented 7 years ago

We need a logging function. A log-level setting would be nice, so that we can log different things depending on a flag.

Volzy commented 7 years ago

Definitely. I can look at that.

Volzy commented 7 years ago

Where do we want to put the environment logic?

Saturate commented 7 years ago

I'm thinking we should use https://github.com/chalk/chalk and do something like

log('INFO', 'We just did something') If we always want to show it

log('DEBUG', 'We just did something that might be useful for debugging to know') If we want it with the debug flag.

log('SILLY', 'This is just stupid, how would need all this information_!')

If you pick a higher log-level you will get all the lower ones as well. I don't know how many levels we will need.

INFO -> DEBUG -> SILLY

I'm thinking somebody before us did something like this, something that we can learn from or steal :-D But would be nice if you looked at it!

Volzy commented 7 years ago

How do you feel about this list of log levels? Seems to be the standard.

  1. Off (0)
  2. Fatal (100)
  3. Error (200)
  4. Warn (300)
  5. Info (400)
  6. Debug (500)
  7. Trace (600)
  8. All (700)

Taken from: https://logging.apache.org/log4j/2.x/manual/customloglevels.html.

If flag is set, then every log level with a lower value is outputted. E.g. --info would output info, warn, error and fatal logs.

Saturate commented 7 years ago

I feel awesome, seems like a very good solution :-) Nothing more to add I guess.

Volzy commented 7 years ago

Related PR #15

Saturate commented 7 years ago

Maybe we should take some inspiration from https://github.com/visionmedia/debug

Volzy commented 7 years ago

This has a single state (debug) and you can run debug for a limited area of your solution. How does this compare to our logging function, where we want to output log from the tasks you run across the solution based on a state you set?

Can you ellaborate on your thoughts?

Saturate commented 7 years ago

Yes, I guess I have to explain a bit more. As you can't readminds :(

The logger should be independent from all other components, so a logger would have to:

Nice to have:

The great thing about not just using debugjs is that we can also log normal things that we want the user to see, and keep the syntax and other nice stuff.

Maybe we could borrow things from them, or wrap their module. But most important is that we don't rely on the configuration reader, but read Environment Variables.

What do you think?

Saturate commented 7 years ago

https://www.npmjs.com/package/debug-logger