Ecdar/j-Ecdar

Log functions with lazily evaluated parameters

Opened this issue · 0 comments

The log functions (debug, info, trace and such) evaluates the parameters even though the urgency blocks the log. For this reason log functions should also provide a way for users to specify a call where the parameters are lazily evaluated. An example is:

    public static void debug(Supplier<String> supplier) {
        if (urgency.level >= Urgency.Debug.level) {
            out(format(supplier.get(), Urgency.Debug));
        }
    }

    // Calling it would look like the following:
   Log.debug(() -> "Hello, World!");

Here the Supplier is only evaluated if we need its value.

Originally posted by @Brandhoej in #74 (comment)