| | | 1 | | using ArturRios.Logging.Configuration; |
| | | 2 | | using ArturRios.Logging.Interfaces; |
| | | 3 | | using ArturRios.Logging.Loggers; |
| | | 4 | | |
| | | 5 | | namespace ArturRios.Logging.Factories; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Factory for creating internal logger instances based on configuration. |
| | | 9 | | /// </summary> |
| | | 10 | | public static class InternalLoggerFactory |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Creates an internal logger instance based on the provided configuration. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="loggerConfiguration">The logger configuration specifying the type and settings.</param> |
| | | 16 | | /// <returns>An instance of <see cref="IInternalLogger"/> configured according to the provided settings.</returns> |
| | | 17 | | /// <exception cref="ArgumentNullException">Thrown when loggerConfiguration is null.</exception> |
| | | 18 | | /// <exception cref="ArgumentException">Thrown when the configuration type is not supported.</exception> |
| | | 19 | | public static IInternalLogger Create(LoggerConfiguration loggerConfiguration) |
| | 6 | 20 | | { |
| | 6 | 21 | | ArgumentNullException.ThrowIfNull(loggerConfiguration); |
| | | 22 | | |
| | 5 | 23 | | return loggerConfiguration switch |
| | 5 | 24 | | { |
| | 2 | 25 | | ConsoleLoggerConfiguration consoleConfig => new ConsoleLogger(consoleConfig), |
| | 2 | 26 | | FileLoggerConfiguration fileConfig => new FileLogger(fileConfig), |
| | 1 | 27 | | _ => throw new ArgumentException($"Unsupported logger configuration type: {loggerConfiguration.GetType().Ful |
| | 5 | 28 | | }; |
| | 4 | 29 | | } |
| | | 30 | | } |