Custom Swift Logger in Xcode 15
Build a lightweight logger for the events in your App
In big or small apps understanding realtime on debug what is happening is crucial. Inspecting the value of a property or reading the json response of a service is an every day task. To perform it you could use breakpoints on Xcode but it is not a fast option. You could use theprint
command but things will get out of hands soon. The best solution is to create a custom logger tailored on your app.
Please note that in the past I have already written an article about it but with the release of Xcode 15 it is time to update the logic. The reason is simple: Apple finally upgraded their logging system removing all the previous verbosity and making it simple to use and read in the Console of Xcode.
As written before, I do not use theprint
command mainly for two reasons:
- It is very easy to leave unwanted stuff in the Production build
- Sometimes it is very hard to understand where the print is coming from, especially if you are printing just the value of an object without any other labels.
Please note that you can find the final project in my Patreon page: