-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Currently we have no clear way how a script developer should create debug logs. Often we use print(...) or console.log(...) statements to write debug output to the terminal, but this is no solution we should use in the future. Therefore I propose we add a dedicated logging module to the script repository. This module should provide a set of logging functions that can be used to log debug output. Behind the scene the new logging module should make use of the existing Java API to log the information in a uniform way with phoenicis.
An open question is how should the logging methods be accessed. I can imagine two approaches
First Approach
The first and most simple approach allows the following access:
const { debug, info, error, warn } = include(...);
...
// later on
info("Start task x");
...This approach has the benefit that it is very easy because you can directly import the required logging methods. An issue with this approach is that it does not allow for additional customization based on the script the logging messages are printed from
Second Approach
The second approach tries to fix the shortcoming of the first approach. It allows the following usage:
const Logger = include(...);
const { debug, info, error, warn } = Logger.create("Zelda");
// or: const { debug, info, error, warn } = new Logger("Zelda");
...
// later on
info("Start task x");
...The disadvantage of this approach is that it requires an additional command before logging can be used.