FluentFTP
FluentFTP copied to clipboard
Improve logging pattern
The easiest thing is to define
public interface IFluentFtpLogger
{
void Debug(string message); //or Verbose() if you prefer
void Info(string message);
void Warning(string message);
void Error(string message);
void Error(string message, Exception ex);
}
public class NullFluentFtpLogger
{
void Debug(string message){} //or Verbose() if you prefer
void Info(string message){}
void Warning(string message){}
void Error(string message){}
void Error(string message, Exception ex){}
}
Your internal default is the null, if someone injects one you use it. It's very easy for anyone to wrap a NLog, log4net or whatever logger into a IFluentFtpLogger and you do not have to bother about dependencies.
If you want to be nice with people, you could provide some implementations like CompositeFluentFtpLogger for using more than one logger or TraceFluentFtpLogger which basically send out on Trace (I'm just suggesting stuff that does not require external deps).
Or were you thinking about something more IoC/DI?
Cheers https://github.com/Adhara3