New console v1.2 release

In November 2024, I opened a pull request to Ottmar Gobrecht’s awesome and easy-to-use logging project “console”. A colleague of mine inspired me to apply the builder pattern to easily log parameters and I wanted to contribute this enhancement to the original project. In December, Ottmar and I sat down to discuss some further enhancements I proposed to him and at the end of a very pleasant conversation I became a co-maintainer for the project. I did not expect my pull request to go such a long way but here we are ;)

After more than 3 years, console now has a new version 1.2.0! In this blog post, I want to go over this new version and show you how to make use of it (in case you haven’t heard of console, check out Ottmar’s introduction to logging that doesn’t get in your way).

Parameter chaining

This version brings the builder pattern to parameter logging. As I already described in this blog post, the builder pattern makes use of object types to chain multiple function calls together. In practice, this looks like this:

begin
  my_object()
    .function_call()
    .another_function_call()
    .really_the_last_call();
end;

This saves some typing as you don’t have to specify the object (or package) for each function call.

The way we integrated this in to the console-Project, is by enabling the chaining of parameters. Previously, you would log your parameters like this:

create or replace procedure test_proc(
  i_param_1 number
  ,i_param_2 date
  ,i_param_3 varchar2
) as
begin
  console.add_param('i_param_1', i_param_1);
  console.add_param('i_param_2', i_param_2);
  console.add_param('i_param_3', i_param_3);
end test_proc;

With the advent of parameter chaining, this would now look like this (of course you can still use the old style):

create or replace procedure test_proc(
  i_param_1 number
  ,i_param_2 date
  ,i_param_3 varchar2
) as
begin
  console.add_param('i_param_1', i_param_1)
    .add_param('i_param_2', i_param_2)
    .add_param('i_param_3', i_param_3);
end test_proc;

Much more elegant, don’t you agree?

To enable this, we introduced a new object type t_console that is returned by the first call to console.add_param. This object type has a member function (and procedure) for each possible parameter type which, again, returns an object of type t_console.

Stay tuned!

You can install the new version by simply running @https://raw.githubusercontent.com/ogobrecht/console/main/install/create_console_objects.sql in SQLcl and you’re good to go. Let us know what you think!

In the meantime, we will be busy enhancing the project by introducing a more robust test suite and some additional features. I am really glad to be a part of this project and hope it can help you to worry less about logging and write more code. So, stay tuned for future releases!