New App - Console Logger [Deprecated]

Edit:

Note: This approach has been replaced with the usage of OSLog.

Introduction:

When starting a new app, I usually like to set up a console logger right from the scratch.

I like to use a simple enum with different verbosity levels:

Logger:

SwiftUI view to change the verbosity

I also like to have a Picker to display inside a DeveloperMenu to change the verbosity:

It looks like this:

picker

Usage

With this code in place, you can call the Logger directly from any place in your app:

Logger.log(.err, "Something went wrong")

log-error


Network Logger

I’ve also written a post about a NetworkLogger, for logging information about networking requests/responses/object decoding/etc.

Do you use some sort of console logger in your apps?

New App - Console Logger [Deprecated] | manu.show
Tags: iOS tools
Share: X (Twitter) LinkedIn