Ejemplo n.º 1
0
            private static TraceEventType GetTraceEventType(LogLevel logLevel)
            {
                switch (logLevel)
                {
                case LogLevel.Fatal:
                    return(TraceEventType.Critical);

                case LogLevel.Error:
                    return(TraceEventType.Error);

                case LogLevel.Warn:
                    return(TraceEventType.Warning);

                case LogLevel.Info:
                    return(TraceEventType.Information);

                case LogLevel.Trace:
                case LogLevel.Debug:
                    return(TraceEventType.Verbose);
                }

                return(TraceEventType.Warning);
            }
Ejemplo n.º 2
0
            public bool Log(LogLevel logLevel, Func <string> messageFunc, Exception exception,
                            params object[] formatParameters)
            {
                if (exception is OperationCanceledException)
                {
                    return(true);
                }

                if (messageFunc != null)
                {
                    var eventType = GetTraceEventType(logLevel);

                    var message = FormatMessage(messageFunc, formatParameters);

                    LoggingService.LogEntry(nameof(WampLogger), message, LoggingService.Category.General, eventType);
                }

                if (exception != null)
                {
                    Core.Log.LogError(nameof(WampLogger), exception);
                }

                return(true);
            }