示例#1
0
        public static Dictionary <string, string> ToDictionary(this ILoggerProperties properties)
        {
            if (properties == null)
            {
                return(null);
            }

            var newDict = new Dictionary <string, string>();
            var typen   = properties.GetType();

            foreach (var propInfo in typen.GetProperties())
            {
                var propValue       = propInfo.GetValue(properties, null);
                var dictionaryValue = propValue?.ToString() ?? null;

                newDict.Add(propInfo.Name, dictionaryValue);
            }

            return(newDict);
        }
示例#2
0
 public void Debug(string text, ILoggerProperties properties = null)
 {
     Console.Out.WriteLine(text);
 }
示例#3
0
 public void CustomEvent(string text, ILoggerProperties properties = null)
 {
     Console.Out.WriteLine(text);
 }
示例#4
0
 public void Fatal(string text, Exception ex, ILoggerProperties properties = null)
 {
     Console.Error.WriteLine($"{text}\n{ex}");
 }
示例#5
0
 public void Fatal(string text, ILoggerProperties properties = null)
 {
     Console.Error.WriteLine(text);
 }
示例#6
0
 public void Warn(string text, Exception ex, ILoggerProperties properties = null)
 {
     Console.Out.WriteLine($"{text}\n{ex}");
 }
示例#7
0
 public void CustomEvent(string text, ILoggerProperties properties = null)
 {
     _telemetryClient.TrackEvent(text, properties.ToDictionary());
     _telemetryClient.Flush();
 }
示例#8
0
 public void Fatal(string text, Exception ex, ILoggerProperties properties = null)
 {
     _telemetryClient.TrackTrace($"{text}\n{ex}", SeverityLevel.Critical, properties.ToDictionary());
     _telemetryClient.TrackException(ex, properties.ToDictionary());
     _telemetryClient.Flush();
 }
示例#9
0
 public void Fatal(string text, ILoggerProperties properties = null)
 {
     _telemetryClient.TrackTrace(text, SeverityLevel.Critical, properties.ToDictionary());
     _telemetryClient.Flush();
 }
示例#10
0
 public void Info(string text, ILoggerProperties properties = null)
 {
     _telemetryClient.TrackTrace(text, SeverityLevel.Information, properties.ToDictionary());
     _telemetryClient.Flush();
 }
示例#11
0
 public void Debug(string text, ILoggerProperties properties = null)
 {
     _telemetryClient.TrackTrace(text, SeverityLevel.Verbose, properties.ToDictionary());
 }
示例#12
0
 public void Fatal(string text, Exception ex, ILoggerProperties properties = null)
 {
     _loggers.ForEach(p => p.Fatal(text, ex, properties));
 }
示例#13
0
 public void Error(string text, ILoggerProperties properties = null)
 {
     _loggers.ForEach(p => p.Error(text, properties));
 }
示例#14
0
 public void Warn(string text, ILoggerProperties properties = null)
 {
     _loggers.ForEach(p => p.Warn(text, properties));
 }
示例#15
0
 public void Debug(string text, ILoggerProperties properties = null)
 {
     _loggers.ForEach(p => p.Debug(text, properties));
 }
示例#16
0
 public void Info(string text, ILoggerProperties properties = null)
 {
     _loggers.ForEach(p => p.Info(text, properties));
 }