Пример #1
0
        public static DiagnosticEvent PrepareDiagnosticEvent(
            SeverityLevel eventSeverity,
            string message = null,
            object[] messageArgs = null,
            Exception exception = null,
            string category = null,
            AttachedObject[] attachedObjects = null)
        {
            var de = new DiagnosticEvent();

            de.Severity = eventSeverity;

            de.Category = category;

            de.ExceptionObject = exception;

            if (message != null)
            {
                if (messageArgs != null)
                    de.GetMessage = () => string.Format(message, messageArgs);
                else
                    de.VerbatimMessage = message;
            }

            de.AttachedObjects.AddRange(attachedObjects);

            return de;
        }
        void ILogger.Event(SeverityLevel severity, string category, params object[] attachedObjects)
        {
            // TODO:
            //if (!ConfigCache.ShouldProcessErrors)
            //  return;

            var de =
                DiagnosticEvent.PrepareDiagnosticEvent(
                    severity,
                    category: category,
                    attachedObjects: attachedObjects.Select((o) => new AttachedObject(o)).ToArray());

            ProcessDiagnosticEvent(de);
        }
Пример #3
0
        public static DiagnosticEvent PrepareDiagnosticEvent(
            SeverityLevel logLevel,
            Func<string> getMessage,
            Exception exception = null,
            string category = null,
            AttachedObject[] attachedObjects = null)
        {
            var de = new DiagnosticEvent();

            de.Severity = logLevel;

            de.Category = category;

            de.ExceptionObject = exception;

            de.GetMessage = getMessage;

            de.AttachedObjects.AddRange(attachedObjects);

            return de;
        }
        void ILogger.Event(SeverityLevel severity, string category)
        {
            // TODO:
            //if (!ConfigCache.ShouldProcessErrors)
            //  return;

            var de =
                DiagnosticEvent.PrepareDiagnosticEvent(
                    severity,
                    category: category);

            ProcessDiagnosticEvent(de);
        }