EasyLog for logging and debugging



EasyLog allows you to start logging any method or all class’s methods by adding just one annotation @LogIt.

    @LogIt
    public Universe bigBang(int numberOfStars) {
        ...
    }

You’ll get this

13:36:06.021 [main] INFO  UneasyLogger - 
-> public Universe Universe.bigBang(int numberOfStars)
"numberOfStars": 1

13:36:06.205 [main] INFO  UneasyLogger - 
Execution/Response time:  162ms
<- Universe Universe.bigBang(int numberOfStars)
{
  "stars": [
    {
      "name": "Star-b90637a4-81bb-4c46-9c05-99ecf2dc0502",
      "type": "RED_GIANT",
      "planets": [
        {
          "name": "Planet-c5308178-4ebe-46c6-a02a-f78d489afc99",
          "haveSatellites": true
        }
      ]
    }
  ],
  "dateOfCreation": "Jun 29, 2018 1:36:06 PM"
}

You can use many features to customize your log output.

For example you can mask one or several field or subfield values (@LogIt(maskFields = {"dateOfCreation"})) then every time when dateOfCreation appears in the logs its value will be replaced with XXXMASKEDXXX

EasyLog for testing

If you are a Test Automation guy (called QA, SDET, Test Automation Engineer or what ever you want to call yourself) then at some point you might realize that developers or other Test Automation people or even yourself are not so excited when you need to figure out why some particular tests started failing. Especially if this is backend tests and there is no UI you can rely on.

In this case you go to your CI/CD tool (Jenkins, Bamboo etc) and look at the failure in the test report and the console output. And what do you see usually? In my own experience - almost nothing - a thrown exception or an assertion message as a maximum.

The next step is that you try to run tests locally and debug tests in your IDE. If this is tests for some web service then you add System.out.println(...) or logger.log(..) statements to your tests to see what actual requests and responses are.

If your test contains several calls it gets much more complicated. I can imagine that easily - for example to submit an order you may need 1. Create an order, 2. Update billing address, 3. Update shipping address, 4. Add items to the order, 5. Add card info, 6. Submit.

Our attempts to log as much as possible make our test code unreadable - another evil.

What alternative is available?

Use AOP - Aspect Oriented Programming.

EasyLog is the open source library that actively uses AOP and Java Reflection.

Just add the @LogIt annotation to the method that you want to log, that’s it.

Enjoy!

Back to the top