///
/// Extensions to help make logging awesome
///
public static class LogExtensions
{
///
/// Concurrent dictionary that ensures only one instance of a logger for a type.
///
private static readonly Lazy> _dictionary = new Lazy>(()=>new ConcurrentDictionary());
///
/// Gets the logger for .
///
///
/// The type to get the logger for.
/// Instance of a logger for the object.
public static ILog Log(this T type)
{
string objectName = typeof(T).FullName;
return Log(objectName);
}
///
/// Gets the logger for the specified object name.
///
/// Either use the fully qualified object name or the short. If used with Log<T>() you must use the fully qualified object name"/>
/// Instance of a logger for the object.
public static ILog Log(this string objectName)
{
return _dictionary.Value.GetOrAdd(objectName, Infrastructure.Logging.Log.GetLoggerFor);
}
}