CBielstein / APRSsharp

APRS# - Modern APRS software for the amateur radio community
MIT License
12 stars 5 forks source link

Make `ILogger` Parameter Optional on `AprsIsClient` #127

Open CBielstein opened 2 years ago

CBielstein commented 2 years ago

Description

Currently, AprsIsClient requires an ILogger parameter. This is extremely useful for additional information output (and logging when used in web servers). However, that makes the code slightly more difficult to call for new developers or in situations where a logger is not needed.

To help ease development, we should make the logger parameter to AprsIsClient's constructor optional (nullable, default to null) and do one of the following if the parameter is not supplied:

  1. Set the logger in the client to null and ensure all invocations of it use conditional dereference (e.g. (logger?.LogInformation(...);)
  2. Set a non-null logger of NullLogger class like in the unit tests, then it will log to nowhere

I suspect the first option is probably the best option as a null value clearly indicates the intent of not having a logger.

Acceptance Criteria