From a6647ca697f3775c2811d402cae287abec08dc2d Mon Sep 17 00:00:00 2001 From: Damian Hickey Date: Sat, 28 Mar 2015 21:20:14 +0100 Subject: [PATCH] Change the conditional compilation symbol for LIBLOG_PUBLIC to LIBLOG_INTERNAL, meaning ILog, LogLevel and LogProvider.SetCurrentClassLogger() will remain public. Made internal a bunch of other previous public methods. --- src/LibLog/LibLog.cs | 73 +++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/src/LibLog/LibLog.cs b/src/LibLog/LibLog.cs index 98ac3c3..b2ffa32 100644 --- a/src/LibLog/LibLog.cs +++ b/src/LibLog/LibLog.cs @@ -27,6 +27,7 @@ // ReSharper disable PossibleNullReferenceException // Define LIBLOG_PORTABLE conditional compilation symbol for PCL compatibility +// Define LIBLOG_INTERNAL to make ALL otherwise public types internal #pragma warning disable 1591 @@ -42,10 +43,10 @@ namespace LibLog.Logging /// /// Simple interface that represent a logger. /// -#if LIBLOG_PUBLIC - public -#else +#if LIBLOG_INTERNAL internal +#else + public #endif interface ILog { @@ -69,7 +70,12 @@ interface ILog /// /// The log level. /// - public enum LogLevel +#if LIBLOG_INTERNAL + internal +#else + public +#endif + enum LogLevel { Trace, Debug, @@ -79,12 +85,7 @@ public enum LogLevel Fatal } -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static class LogExtensions + internal static class LogExtensions { public static bool IsDebugEnabled(this ILog logger) { @@ -337,7 +338,12 @@ private static T Return(this T value) /// /// Represents a way to get a /// - public interface ILogProvider +#if LIBLOG_INTERNAL + internal +#else + public +#endif + interface ILogProvider { /// /// Gets the specified named logger. @@ -365,7 +371,12 @@ public interface ILogProvider /// /// Provides a mechanism to create instances of objects. /// - public static class LogProvider +#if LIBLOG_INTERNAL + internal +#else + public +#endif + static class LogProvider { private const string NullLogProvider = "Current Log Provider is not set. Call SetCurrentLogProvider " + @@ -413,12 +424,7 @@ internal static ILogProvider CurrentLogProvider /// /// The type whose name will be used for the logger. /// An instance of -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static ILog For() + internal static ILog For() { return GetLogger(typeof(T)); } @@ -428,12 +434,7 @@ static ILog For() /// Gets a logger for the current class. /// /// An instance of -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static ILog GetCurrentClassLogger() + internal static ILog GetCurrentClassLogger() { var stackFrame = new StackFrame(1, false); return GetLogger(stackFrame.GetMethod().DeclaringType); @@ -445,12 +446,7 @@ static ILog GetCurrentClassLogger() /// /// The type whose name will be used for the logger. /// An instance of -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static ILog GetLogger(Type type) + internal static ILog GetLogger(Type type) { return GetLogger(type.FullName); } @@ -460,18 +456,13 @@ static ILog GetLogger(Type type) /// /// The name. /// An instance of -#if LIBLOG_PUBLIC - public -#else - internal -#endif - static ILog GetLogger(string name) + internal static ILog GetLogger(string name) { ILogProvider logProvider = CurrentLogProvider ?? ResolveLogProvider(); return logProvider == null ? new NoOpLogger() : (ILog)new LoggerExecutionWrapper(logProvider.GetLogger(name)); } - public static IDisposable OpenNestedConext(string message) + internal static IDisposable OpenNestedConext(string message) { if(CurrentLogProvider == null) { @@ -480,7 +471,7 @@ public static IDisposable OpenNestedConext(string message) return CurrentLogProvider.OpenNestedContext(message); } - public static IDisposable OpenMappedContext(string key, string value) + internal static IDisposable OpenMappedContext(string key, string value) { if (CurrentLogProvider == null) { @@ -489,11 +480,11 @@ public static IDisposable OpenMappedContext(string key, string value) return CurrentLogProvider.OpenMappedContext(key, value); } - public delegate bool IsLoggerAvailable(); + internal delegate bool IsLoggerAvailable(); - public delegate ILogProvider CreateLogProvider(); + internal delegate ILogProvider CreateLogProvider(); - public static readonly List> LogProviderResolvers = + internal static readonly List> LogProviderResolvers = new List> { new Tuple(SerilogLogProvider.IsLoggerAvailable, () => new SerilogLogProvider()),