Example #1
0
        public Task LogAsync(LogMessage msg)
        {
            // Variables declaration
            string message = msg.Exception?.ToString() ?? msg.Message;

            // Use different loggers for different severity levels
            switch (msg.Severity)
            {
            case LogSeverity.Critical:
                _logger.LogCritical(message);
                break;

            case LogSeverity.Error:
                _logger.LogError(message);
                break;

            case LogSeverity.Warning:
                _logger.LogWarning(message);
                break;

            case LogSeverity.Info:
                _logger.LogInformation(message);
                break;

            case LogSeverity.Debug:
                _logger.LogDebug(message);
                break;

            default:
                _logger.LogDefault(message);
                break;
            }

            // Log to filesystem.
            // W.I.P

            // Once all tasks have been completed, return 'Task.CompletedTask'
            return(Task.CompletedTask);
        }