|
| 1 | +using System; |
| 2 | +using Cake.Core; |
| 3 | +using Cake.Core.Annotations; |
| 4 | +using Cake.Core.Diagnostics; |
| 5 | + |
| 6 | +namespace Cake.Common.Diagnostics; |
| 7 | + |
| 8 | +public static partial class LoggingAliases |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Writes an error message to the log using the specified format information. |
| 12 | + /// </summary> |
| 13 | + /// <param name="context">The context.</param> |
| 14 | + /// <param name="formattable">The string to be formatted.</param> |
| 15 | + /// <example> |
| 16 | + /// <code> |
| 17 | + /// Error($"Hello {"World"}! Today is an {DateTime.Now:dddd}"); |
| 18 | + /// </code> |
| 19 | + /// </example> |
| 20 | + [CakeMethodAlias] |
| 21 | + [CakeAliasCategory("Error")] |
| 22 | + public static void Error(this ICakeContext context, FormattableString formattable) |
| 23 | + { |
| 24 | + ArgumentNullException.ThrowIfNull(context); |
| 25 | + context.Log.Error(formattable); |
| 26 | + } |
| 27 | + |
| 28 | + /// <summary> |
| 29 | + /// Writes an warning message to the log using the specified format information. |
| 30 | + /// </summary> |
| 31 | + /// <param name="context">The context.</param> |
| 32 | + /// <param name="formattable">The string to be formatted.</param> |
| 33 | + /// <example> |
| 34 | + /// <code> |
| 35 | + /// Warning($"Hello {"World"}! Today is an {DateTime.Now:dddd}"); |
| 36 | + /// </code> |
| 37 | + /// </example> |
| 38 | + [CakeMethodAlias] |
| 39 | + [CakeAliasCategory("Warning")] |
| 40 | + public static void Warning(this ICakeContext context, FormattableString formattable) |
| 41 | + { |
| 42 | + ArgumentNullException.ThrowIfNull(context); |
| 43 | + context.Log.Warning(formattable); |
| 44 | + } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// Writes an informational message to the log using the specified formattable string. |
| 48 | + /// </summary> |
| 49 | + /// <param name="context">The context.</param> |
| 50 | + /// <param name="formattable">The string to be formatted.</param> |
| 51 | + /// <example> |
| 52 | + /// <code> |
| 53 | + /// Information($"Hello {"World"}! Today is an {DateTime.Now:dddd}"); |
| 54 | + /// </code> |
| 55 | + /// </example> |
| 56 | + [CakeMethodAlias] |
| 57 | + [CakeAliasCategory("Information")] |
| 58 | + public static void Information(this ICakeContext context, FormattableString formattable) |
| 59 | + { |
| 60 | + ArgumentNullException.ThrowIfNull(context); |
| 61 | + context.Log.Information(formattable); |
| 62 | + } |
| 63 | + |
| 64 | + /// <summary> |
| 65 | + /// Writes an verbose message to the log using the specified formattable string. |
| 66 | + /// </summary> |
| 67 | + /// <param name="context">The context.</param> |
| 68 | + /// <param name="formattable">The string to be formatted.</param> |
| 69 | + /// <example> |
| 70 | + /// <code> |
| 71 | + /// Verbose($"Hello {"World"}! Today is an {DateTime.Now:dddd}"); |
| 72 | + /// </code> |
| 73 | + /// </example> |
| 74 | + [CakeMethodAlias] |
| 75 | + [CakeAliasCategory("Verbose")] |
| 76 | + public static void Verbose(this ICakeContext context, FormattableString formattable) |
| 77 | + { |
| 78 | + ArgumentNullException.ThrowIfNull(context); |
| 79 | + context.Log.Verbose(formattable); |
| 80 | + } |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// Writes an debug message to the log using the specified formattable string. |
| 84 | + /// </summary> |
| 85 | + /// <param name="context">The context.</param> |
| 86 | + /// <param name="formattable">The string to be formatted.</param> |
| 87 | + /// <example> |
| 88 | + /// <code> |
| 89 | + /// Debug($"Hello {"World"}! Today is an {DateTime.Now:dddd}"); |
| 90 | + /// </code> |
| 91 | + /// </example> |
| 92 | + [CakeMethodAlias] |
| 93 | + [CakeAliasCategory("Debug")] |
| 94 | + public static void Debug(this ICakeContext context, FormattableString formattable) |
| 95 | + { |
| 96 | + ArgumentNullException.ThrowIfNull(context); |
| 97 | + context.Log.Debug(formattable); |
| 98 | + } |
| 99 | + |
| 100 | + /// <summary> |
| 101 | + /// Writes an error message to the log using the specified format information. |
| 102 | + /// </summary> |
| 103 | + /// <param name="context">The context.</param> |
| 104 | + /// <param name="formattableLogAction">The log action.</param> |
| 105 | + /// <example> |
| 106 | + /// <code> |
| 107 | + /// Error(logAction => logAction($"Hello {"World"}! Today is an {DateTime.Now:dddd}")); |
| 108 | + /// </code> |
| 109 | + /// </example> |
| 110 | + [CakeMethodAlias] |
| 111 | + [CakeAliasCategory("Error")] |
| 112 | + public static void Error(this ICakeContext context, FormattableLogAction formattableLogAction) |
| 113 | + { |
| 114 | + ArgumentNullException.ThrowIfNull(context); |
| 115 | + context.Log.Error(formattableLogAction); |
| 116 | + } |
| 117 | + |
| 118 | + /// <summary> |
| 119 | + /// Writes an warning message to the log using the specified format information. |
| 120 | + /// </summary> |
| 121 | + /// <param name="context">The context.</param> |
| 122 | + /// <param name="formattableLogAction">The log action.</param> |
| 123 | + /// <example> |
| 124 | + /// <code> |
| 125 | + /// Warning(logAction => logAction($"Hello {"World"}! Today is an {DateTime.Now:dddd}")); |
| 126 | + /// </code> |
| 127 | + /// </example> |
| 128 | + [CakeMethodAlias] |
| 129 | + [CakeAliasCategory("Warning")] |
| 130 | + public static void Warning(this ICakeContext context, FormattableLogAction formattableLogAction) |
| 131 | + { |
| 132 | + ArgumentNullException.ThrowIfNull(context); |
| 133 | + context.Log.Warning(formattableLogAction); |
| 134 | + } |
| 135 | + |
| 136 | + /// <summary> |
| 137 | + /// Writes an informational message to the log using the specified formattable string. |
| 138 | + /// </summary> |
| 139 | + /// <param name="context">The context.</param> |
| 140 | + /// <param name="formattableLogAction">The log action.</param> |
| 141 | + /// <example> |
| 142 | + /// <code> |
| 143 | + /// Information(logAction => logAction($"Hello {"World"}! Today is an {DateTime.Now:dddd}")); |
| 144 | + /// </code> |
| 145 | + /// </example> |
| 146 | + [CakeMethodAlias] |
| 147 | + [CakeAliasCategory("Information")] |
| 148 | + public static void Information(this ICakeContext context, FormattableLogAction formattableLogAction) |
| 149 | + { |
| 150 | + ArgumentNullException.ThrowIfNull(context); |
| 151 | + context.Log.Information(formattableLogAction); |
| 152 | + } |
| 153 | + |
| 154 | + /// <summary> |
| 155 | + /// Writes an verbose message to the log using the specified formattable string. |
| 156 | + /// </summary> |
| 157 | + /// <param name="context">The context.</param> |
| 158 | + /// <param name="formattableLogAction">The log action.</param> |
| 159 | + /// <example> |
| 160 | + /// <code> |
| 161 | + /// Verbose(logAction => logAction($"Hello {"World"}! Today is an {DateTime.Now:dddd}")); |
| 162 | + /// </code> |
| 163 | + /// </example> |
| 164 | + [CakeMethodAlias] |
| 165 | + [CakeAliasCategory("Verbose")] |
| 166 | + public static void Verbose(this ICakeContext context, FormattableLogAction formattableLogAction) |
| 167 | + { |
| 168 | + ArgumentNullException.ThrowIfNull(context); |
| 169 | + context.Log.Verbose(formattableLogAction); |
| 170 | + } |
| 171 | + |
| 172 | + /// <summary> |
| 173 | + /// Writes an debug message to the log using the specified formattable string. |
| 174 | + /// </summary> |
| 175 | + /// <param name="context">The context.</param> |
| 176 | + /// <param name="formattableLogAction">The log action.</param> |
| 177 | + /// <example> |
| 178 | + /// <code> |
| 179 | + /// Debug(logAction => logAction($"Hello {"World"}! Today is an {DateTime.Now:dddd}")); |
| 180 | + /// </code> |
| 181 | + /// </example> |
| 182 | + [CakeMethodAlias] |
| 183 | + [CakeAliasCategory("Debug")] |
| 184 | + public static void Debug(this ICakeContext context, FormattableLogAction formattableLogAction) |
| 185 | + { |
| 186 | + ArgumentNullException.ThrowIfNull(context); |
| 187 | + context.Log.Debug(formattableLogAction); |
| 188 | + } |
| 189 | +} |
0 commit comments