Пример #1
0
        private void LogMessage(IAuditEntry audit)
        {
            var logTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {@Message}{NewLine}{Exception}";

            // TODO: do not use audit type to determine log level of audit entry
            switch (audit.AuditType)
            {
            case "Information":
                _publisher.Info(logTemplate, DateTime.Now, LogEventLevel.Information, audit);
                break;

            case "Warning":
                _publisher.Warn(logTemplate, DateTime.Now, LogEventLevel.Warning, audit);
                break;

            case "Error":
                _publisher.Error(logTemplate, DateTime.Now, LogEventLevel.Error, audit, Environment.NewLine, audit.Exception);
                break;

            case "Fatal":
                _publisher.Fatal(logTemplate, DateTime.Now, LogEventLevel.Fatal, audit, Environment.NewLine, audit.Exception);
                break;

            default:
                _publisher.Debug(logTemplate, DateTime.Now, LogEventLevel.Debug, audit);
                break;
            }
        }
Пример #2
0
        private void LogMessage(IAuditEntry audit)
        {
            var logTemplate = GlobalConstants.WarewolfLogsTemplate;

            switch (audit.LogLevel)
            {
            case LogLevel.Info:
                _publisher.Info(logTemplate, audit);
                break;

            case LogLevel.Warn:
                _publisher.Warn(logTemplate, audit);
                break;

            case LogLevel.Error:
                _publisher.Error(logTemplate, audit);
                break;

            case LogLevel.Fatal:
                _publisher.Fatal(logTemplate, audit.Exception);
                break;

            default:
                _publisher.Debug(logTemplate, audit);
                break;
            }
        }