Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
Change the conditional compilation symbol for LIBLOG_PUBLIC to LIBLOG…
Browse files Browse the repository at this point in the history
…_INTERNAL, meaning ILog, LogLevel and LogProvider.SetCurrentClassLogger() will remain public. Made internal a bunch of other previous public methods.
  • Loading branch information
damianh committed Mar 28, 2015
1 parent 3de0e07 commit a6647ca
Showing 1 changed file with 32 additions and 41 deletions.
73 changes: 32 additions & 41 deletions src/LibLog/LibLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -42,10 +43,10 @@ namespace LibLog.Logging
/// <summary>
/// Simple interface that represent a logger.
/// </summary>
#if LIBLOG_PUBLIC
public
#else
#if LIBLOG_INTERNAL
internal
#else
public
#endif
interface ILog
{
Expand All @@ -69,7 +70,12 @@ interface ILog
/// <summary>
/// The log level.
/// </summary>
public enum LogLevel
#if LIBLOG_INTERNAL
internal
#else
public
#endif
enum LogLevel
{
Trace,
Debug,
Expand All @@ -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)
{
Expand Down Expand Up @@ -337,7 +338,12 @@ private static T Return<T>(this T value)
/// <summary>
/// Represents a way to get a <see cref="ILog"/>
/// </summary>
public interface ILogProvider
#if LIBLOG_INTERNAL
internal
#else
public
#endif
interface ILogProvider
{
/// <summary>
/// Gets the specified named logger.
Expand Down Expand Up @@ -365,7 +371,12 @@ public interface ILogProvider
/// <summary>
/// Provides a mechanism to create instances of <see cref="ILog" /> objects.
/// </summary>
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 " +
Expand Down Expand Up @@ -413,12 +424,7 @@ internal static ILogProvider CurrentLogProvider
/// </summary>
/// <typeparam name="T">The type whose name will be used for the logger.</typeparam>
/// <returns>An instance of <see cref="ILog"/></returns>
#if LIBLOG_PUBLIC
public
#else
internal
#endif
static ILog For<T>()
internal static ILog For<T>()
{
return GetLogger(typeof(T));
}
Expand All @@ -428,12 +434,7 @@ static ILog For<T>()
/// Gets a logger for the current class.
/// </summary>
/// <returns>An instance of <see cref="ILog"/></returns>
#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);
Expand All @@ -445,12 +446,7 @@ static ILog GetCurrentClassLogger()
/// </summary>
/// <param name="type">The type whose name will be used for the logger.</param>
/// <returns>An instance of <see cref="ILog"/></returns>
#if LIBLOG_PUBLIC
public
#else
internal
#endif
static ILog GetLogger(Type type)
internal static ILog GetLogger(Type type)
{
return GetLogger(type.FullName);
}
Expand All @@ -460,18 +456,13 @@ static ILog GetLogger(Type type)
/// </summary>
/// <param name="name">The name.</param>
/// <returns>An instance of <see cref="ILog"/></returns>
#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)
{
Expand All @@ -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)
{
Expand All @@ -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<Tuple<IsLoggerAvailable, CreateLogProvider>> LogProviderResolvers =
internal static readonly List<Tuple<IsLoggerAvailable, CreateLogProvider>> LogProviderResolvers =
new List<Tuple<IsLoggerAvailable, CreateLogProvider>>
{
new Tuple<IsLoggerAvailable, CreateLogProvider>(SerilogLogProvider.IsLoggerAvailable, () => new SerilogLogProvider()),
Expand Down

0 comments on commit a6647ca

Please sign in to comment.