C# Interfaces Extensibility 3


This entry is part 6 of 8 in the series C# Interfaces

This post continues from the previous post C# Interfaces Extensibility 2.

    public class FileLogger : ILogger
    {
        private readonly string _path;
        public FileLogger(string path)
        {
            _path = path;
        }
        public void LogError(string message)
        {
            Log(message, "ERROR");
        }
        public void LogInfo(string message)
        {
            Log(message, "INFO");
        }
        private void Log(string message, string messageType)
        {
            using (var streamWriter = new StreamWriter(_path, true))
            {
                streamWriter.WriteLine(messageType + ": " + message);
            }
        }
    }
Series Navigation<< C# Interfaces Extensibility 2C# Interfaces Illustrated >>