Browse files

Provide mechanism for default portable impls of platform dependencies…

… and put placeholder for an IDebugOutput adapter
  • Loading branch information...
1 parent d0dbd80 commit 27e756e0dd4a7ccc8befeecc30eac9206e1e44a4 @onovotny committed Sep 17, 2012
View
16 MetroLog/DebugOutput.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MetroLog
+{
+ internal sealed class DebugOutput : IDebugOutput
+ {
+ public void WriteLine(string message)
+ {
+ // No-op
+ }
+ }
+}
View
13 MetroLog/IDebugOutput.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MetroLog
+{
+ public interface IDebugOutput
+ {
+ void WriteLine(string message);
+ }
+}
View
18 MetroLog/Internal/LogManager.cs
@@ -59,16 +59,17 @@ public ILogger GetLogger(Type type, LoggingConfiguration config = null)
/// <param name="name">The name of the logger.</param>
/// <param name="config">An optional configuration value.</param>
/// <returns>The requested logger.</returns>
- public ILogger GetLogger(string name = null, LoggingConfiguration config = null)
+ public ILogger GetLogger(string name, LoggingConfiguration config = null)
{
+ if (string.IsNullOrWhiteSpace(name))
+ throw new ArgumentNullException("name");
+
lock (_loggersLock)
{
if (!(_loggers.ContainsKey(name)))
{
- var logger = new Logger(name, config ?? DefaultConfiguration)
- {
- Manager = this
- };
+ var logger = new Logger(name, config ?? DefaultConfiguration);
+ InternalLogger.Current.Info("Created Logger '{0}'", name);
// call...
this.OnLoggerCreatedSafe(new LoggerEventArgs(logger));
@@ -92,10 +93,11 @@ private void OnLoggerCreatedSafe(LoggerEventArgs args)
}
}
- protected virtual void OnLoggerCreated(LoggerEventArgs args)
+ private void OnLoggerCreated(LoggerEventArgs args)
{
- if (this.LoggerCreated != null)
- this.LoggerCreated(this, args);
+ var evt = LoggerCreated;
+ if (evt != null)
+ evt(this, args);
}
// logs problems with the framework to Debug...
View
1 MetroLog/Internal/Logger.cs
@@ -11,7 +11,6 @@ internal class Logger : ILogger, ILoggerAsync, ILoggerQuery
{
public string Name { get; private set; }
private readonly LoggingConfiguration _configuration;
- protected internal ILogManager Manager { get; internal set; }
internal Logger(string name, LoggingConfiguration config)
{
View
7 MetroLog/Internal/ProbingAdapterResolver.cs
@@ -60,7 +60,12 @@ private static object ResolveAdapter(Assembly assembly, Type interfaceType)
Type type = assembly.GetType(typeName);
if (type != null)
return Activator.CreateInstance(type);
-
+
+ // Fallback to looking in this assembly for a default
+ type = typeof (ProbingAdapterResolver).GetTypeInfo().Assembly.GetType(typeName);
+ if (type != null)
+ return Activator.CreateInstance(type);
+
return type;
}
catch
View
4 MetroLog/InternalLogger.cs
@@ -9,7 +9,7 @@ namespace MetroLog
{
public class InternalLogger : ILogger
{
- private static InternalLogger _current;
+ private static readonly InternalLogger _current;
private InternalLogger()
{
@@ -117,7 +117,7 @@ public void Log(LogLevel logLevel, string message, Exception ex)
// debug...
System.Diagnostics.Debug.WriteLine(formatted);
-
+ PlatformAdapter.Resolve<IDebugOutput>().WriteLine(formatted);
// TODO: EWT
}
View
13 MetroLog/LogConfigurator.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MetroLog.Internal;
+
+namespace MetroLog
+{
+ internal sealed class LogConfigurator : LogConfiguratorBase
+ {
+ }
+}
View
16 MetroLog/LoggingEnvironment.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MetroLog.Internal;
+
+namespace MetroLog
+{
+ internal class LoggingEnvironment : LoggingEnvironmentBase
+ {
+ public LoggingEnvironment() : base("Unknown")
+ {
+ }
+ }
+}
View
4 MetroLog/MetroLog.csproj
@@ -107,8 +107,11 @@
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
+ <Compile Include="DebugOutput.cs" />
<Compile Include="ExceptionWrapper.cs" />
+ <Compile Include="IDebugOutput.cs" />
<Compile Include="ILogConfigurator.cs" />
+ <Compile Include="LogConfigurator.cs" />
<Compile Include="LoggerEventArgs.cs" />
<Compile Include="ILoggerQuery.cs" />
<Compile Include="ILoggingEnvironment.cs" />
@@ -130,6 +133,7 @@
<Compile Include="LogEventInfo.cs" />
<Compile Include="Internal\Logger.cs" />
<Compile Include="LoggingConfiguration.cs" />
+ <Compile Include="LoggingEnvironment.cs" />
<Compile Include="LogWriteContext.cs" />
<Compile Include="LogLevel.cs" />
<Compile Include="Internal\LogManager.cs" />
View
4 SharedAssemblyInfo.cs
@@ -22,8 +22,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.6.1.0")]
-[assembly: AssemblyFileVersion("0.6.1.0")]
+[assembly: AssemblyVersion("0.6.2.0")]
+[assembly: AssemblyFileVersion("0.6.2.0")]
[assembly: InternalsVisibleTo("MetroLog.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001002b4b7e56af036d" +
"ed95a703d3ffc367837e047f6fbdba8fae1d1295a5c031a108aa452c62f14b7a12766f86a0f94f" +

0 comments on commit 27e756e

Please sign in to comment.