| | | 1 | | using ArturRios.Extensions; |
| | | 2 | | |
| | | 3 | | namespace ArturRios.Logging.Factories; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Factory for creating formatted log entry strings. |
| | | 7 | | /// </summary> |
| | | 8 | | public static class LogEntryFactory |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Creates a formatted log entry string with timestamp, log level, class name, method name, and message. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <param name="level">The log level.</param> |
| | | 14 | | /// <param name="filePath">The source file path.</param> |
| | | 15 | | /// <param name="methodName">The calling method name.</param> |
| | | 16 | | /// <param name="message">The log message.</param> |
| | | 17 | | /// <returns>A formatted log entry string.</returns> |
| | | 18 | | public static string Create(CustomLogLevel level, string filePath, string methodName, string message) |
| | 88 | 19 | | { |
| | 88 | 20 | | var logLevel = level.GetDescription()!; |
| | 88 | 21 | | var className = Path.GetFileNameWithoutExtension(filePath); |
| | 88 | 22 | | var timestamp = DateTime.UtcNow.ToString("o"); |
| | | 23 | | |
| | 88 | 24 | | return $"{logLevel}: {className} | {methodName} | {timestamp} | {message}{Environment.NewLine}"; |
| | 88 | 25 | | } |
| | | 26 | | } |