I’m delighted to follow up on my previous article on Optimising Log Retrieval in IDN , which garnered positive feedback. In this installment, we’re taking our approach to the next level.

In the context of our internal cloud system, log lines may not arrive in proper order. Consequently, when these log lines are retrieved and presented, users often face the challenge of manually rearranging them. Moreover, if a logging line is executed multiple times (such as in a loop), managing multiple entries can be cumbersome, making it difficult to discern the chronological sequence.

Let’s revisit one of the examples from the prior article to illustrate how log lines are currently written:

By adopting a slight modification to this method, we can write multiple log lines with a standardized prefix to easily identify the associated identity.

Taking it a step further, we introduce a logNumber and encapsulate the entire logging structure into a method that is repeatedly executed:

Key differences from the previous code include the introduction of logNumber as a newly initiated counter and the implementation of the logMessage method, which is executed on every line, printing the logNumber and incrementing it accordingly.

The result of this modified code is a more streamlined output, exemplified as follows:

While I won’t provide a full code execution example here, it’s evident how this approach simplifies handling logs in loops or complex rules with multiple log lines, making it easier to decipher the order of execution.

To summarize the main advantages:

  1. Single method to streamline the logging mechanism.
  2. logNumber facilitates pattern-following, making it easy to discern the execution order.
  3. A single instance of log.error, easily adaptable to log.info or other log levels without the need to edit each log line individually.

I collaborated on this work with my colleague Kenny Li, a Senior Solution Architect at SailPoint, with whom we together transformed my individual works into an easily applicable method.

As this will likely be my last blog for the year, I wish you all a Merry Christmas and a Happy New Year!!!


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.