As your codebase grows and your system increases in complexity you need to add logs to be able to understand how your program state varies across execution.
When debugging your system you can use a debugger or add some on-off console.log to understand what is happening in your program execution.
The problem with this approach is that you need to instrument your code to be effective in solving or understanding what is going on.
Conditional Logging
Another way to solve this is to have the logs in place, but only enable them conditionally.
If you enable all the logs are the time, you only get a lot of noise that won't help you.
If you are using JavaScript, you can use the package debug to add logs that are active by the DEBUG environment variable.
What to log conditionally?
HTTP requests can be conditionally logged, so you understand what requests your program is doing and which parameters and responses.
Conditionally logging Event-Driven events can be useful for understanding what events are being emitted in which part of the code.
In short
Instrumenting your codebase gets more important as the size and complexity of your product grows.
Use conditional logging to enable only useful logs for your needs.
Woovi
Woovi is a Startup that enables shoppers to pay as they like. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.
If you want to work with us, we are hiring!
Top comments (0)