Open Saturate opened 7 years ago
Definitely. I can look at that.
Where do we want to put the environment logic?
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!
How do you feel about this list of log levels? Seems to be the standard.
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.
I feel awesome, seems like a very good solution :-) Nothing more to add I guess.
Related PR #15
Maybe we should take some inspiration from https://github.com/visionmedia/debug
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?
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?
We need a logging function. A log-level setting would be nice, so that we can log different things depending on a flag.