|
|
@@ -0,0 +1,81 @@
|
|
|
+using System;
|
|
|
+using System.CodeDom;
|
|
|
+using System.Collections.Concurrent;
|
|
|
+using System.Collections.Generic;
|
|
|
+
|
|
|
+namespace Quadarax.Foundation.Common.Log.Extensions
|
|
|
+{
|
|
|
+ public static class ObjectExt
|
|
|
+ {
|
|
|
+ private static IDictionary<string, ILoggingProvider> _providerCache = new ConcurrentDictionary<string, ILoggingProvider>();
|
|
|
+
|
|
|
+ public static void Log(this object owner, SeverityEnum severity, int code, string message)
|
|
|
+ {
|
|
|
+ if (owner == null)
|
|
|
+ throw new ArgumentNullException(nameof(owner));
|
|
|
+ var provider = GetTypeRegistration(owner);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void Log(this object owner, SeverityEnum severity, string message)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void LogInfo(string message)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void LogDebug(int code, string message)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void LogDebug(string message)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void LogError(int code, string message, Exception e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void LogError(string message, Exception e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ public static void LogError(Exception e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void RegisterThisProvider(this object owner, ILoggingProvider provider = null)
|
|
|
+ {
|
|
|
+ var typeName = owner.GetType().FullName;
|
|
|
+ if (provider == null)
|
|
|
+ provider = ILoggingProvider.CreateDefault();
|
|
|
+ _providerCache.Add(typeName, provider);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static void RegisterType(Type type, ILoggingProvider provider)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static ILoggingProvider GetTypeRegistration(object owner, bool createIfNotExists = true)
|
|
|
+ {
|
|
|
+ var typeName = owner.GetType().FullName;
|
|
|
+ if (!_providerCache.TryGetValue(typeName, out var provider))
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|