EasyFarm.Logging.LogEntry.IncludeExceptionInMessage C# (CSharp) Method

IncludeExceptionInMessage() public method

public IncludeExceptionInMessage ( ) : LogEntry
return LogEntry
        public LogEntry IncludeExceptionInMessage()
        {
            if (Exception == null) return this;

            var extendedMessage = string.Join(
                Environment.NewLine,
                Message,
                Exception?.ToString());

            return new LogEntry(Severity, extendedMessage, Exception);
        }

Usage Example

Exemplo n.º 1
0
        public void Log(LogEntry logEntry)
        {
            var formattedLogEntry = logEntry.IncludeExceptionInMessage();
            var message           = formattedLogEntry.Message;
            var exception         = formattedLogEntry.Exception;

            switch (logEntry.Severity)
            {
            case LoggingEventType.Debug:
                _logger.Debug(exception, message);
                break;

            case LoggingEventType.Information:
                _logger.Info(exception, message);
                break;

            case LoggingEventType.Warning:
                _logger.Warn(exception, message);
                break;

            case LoggingEventType.Error:
                _logger.Error(exception, message);
                break;

            case LoggingEventType.Fatal:
                _logger.Fatal(exception, message);
                break;

            default:
                _logger.Info(exception, message);
                break;
            }
        }
All Usage Examples Of EasyFarm.Logging.LogEntry::IncludeExceptionInMessage