# Week 8 ## Recap This week I spent the large majority of my time implementing the necessary client functionality to enable my to more easily implement Portal features. A portion of that involved finding the right libraries to do both logging and have a well designed command line interface. At the beggining of the week I decided to look into available CLI Java solutions to see what was available. It would have been entirely possible to design one myself but I figured that a library would save me time writing essentially boiler-plate code. I decided to opt for the same library that Besu uses, Picocli as it was set up in an easy to use way with custom Java annotations. I then had to configure it in Gradle and learn how to properly use the library. From there I looked into the many available Java logging solutions. Because they are all basically solving the same problem I decided to use SLF4J on top of Log4J2 to match what Besu is doing. In this way, should the client need to interact with other logging libraries the use of SLF4J would automatically enable that. Once I was able to set up the correct dependencies in Gradle it was a matter of properly configuring Log4J2 in my development environment. I was able to do so and the client is now prepared to have Portal specific implementations added. ## Learning My learning this week mainly consisted of reading documentation for different libraries I was considering using for client functionality. Both for figuring out what CLI solution as well as which logging solution that I wanted to use. I also consulted the Besu codebase to see which libraries were being used there and how they were being used in a client context. In addition to how their dependencies were set up across the entire client. ### Concepts #### Besu Codebase When looking at the Besu codebase this week I mainly wanted to learn how they had implemented CLI and logging solutions. After finding they opted to use external libraries I decided it would be best for me to follow suit. I looked into how Picocli was enabled in Besu, and how its dependency was handled. This led me to looking into the use of spring boot for Gradle to handle different dependency versions. I attempted to set up spring boot on my client but only had partial luck. After running into many errors I decided it would be best to leave spring boot setup for later down the line when I have more dependencies to handle. I also looked into Besu's logging solution. Because Java does not really have a fully capable logger by default, there are a few different libraries to choose from. In the case of Besu, it uses Log4J2 managed by SLF4J which is essentially just an interface that adapts to all of the main third-party Java loggers. Because the choice of logger was basically arbitrary I decided to use the same library setup as Besu. ##### Resources 1. https://github.com/hyperledger/besu #### Picocli After learning that Picocli was used by Besu to handle command line interactions it seemed to be the most logical choice for the Portal Client. Additionally the library is really well documented and there are a large number of guides on its use. Furthermore it is designed for use specifically with Java and is relatively lightweight. I learned about its proper use by both looking through Besu's codebase and the Picocli documentation. I found that it is designed in a really nice way that makes the code very easy to read through the use of custom Java annotations. ##### Resources 1. https://picocli.info/ #### Log4J2 and SLF4J In simalar fashion to how I chose my CLI solution, I also chose the same logging solution as Besu. Because the choice of loggers is essentially arbitrary it made the most sense. I learned about how to properly configure both Log4J2 and SLF4J in a Gradle environment and how to use the different levels of logging priority that are offered. It was also useful to see how the dependencies had been setup in Besu for refference. After following the documentation and some troubleshooting I was able to configure the clients logging. ##### Resources https://logging.apache.org/log4j/2.x/manual/configuration.html https://www.slf4j.org/ ## Tasks As stated above my main priorities this week were to configure a proper CLI and logging solution. I also spent some time trying to setup spring boot to make dependency version handling more simple but ran into many errors with Gradle. This is likely something I will have to look into later on as the dependency handling capabilities of spring boot are quite useful. Outside of actually implementing the CLI it took a little while to learn it's correct usage and to test it once implemented, but I am now satisfied with how it works. Getting the logger to work was less about setting up dependencies and more so about learning how to properly configure it with the XML file that it uses. https://github.com/Dsorken/Java-Portal-Client ## Week 9 Plan My plan going into Week 9 is to begin working on the implementation of Discovery V5 in my client. As well work on setting up any dependencies that it may require to run properly. I am hoping to be able to adapt the Besu solution and trim down any unneeded functionality that only applies to the Besu client.