Implementing cross-platform logging
Now that we have our IoC container, we are going to use dependency injection for logging. Adding customized logging features in cross-platform applications is very useful for tracking operations between all of the different projects. The first step is to add a new folder called Logging
, add a new file called ILogger.cs
, and implement the following:
public interface ILogger { #region Methods void WriteLine(string message); void WriteLineTime(string message, params object[] args); #endregion }
For this example, our logger is going to use the standard Debug
console from System.Diagnostics
with iOS, but in Android we are going to use the extensive logging functionality provided by Android.
Now let's add the Logging
folder in both iOS and Android and implement the following:
public class LoggeriOS : ILogger { #region Public Methods public void WriteLine(string text) { Debug...