| ... | @@ -129,92 +129,6 @@ fn log( | ... | @@ -129,92 +129,6 @@ fn log( |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| 131 | | 131 | |
| 132 | /// Log an emergency message. This log level is intended to be used | | |
| 133 | /// for conditions that cannot be handled and is usually followed by a panic. | | |
| 134 | pub fn emerg( | | |
| 135 | comptime scope: @Type(.EnumLiteral), | | |
| 136 | comptime format: []const u8, | | |
| 137 | args: anytype, | | |
| 138 | ) void { | | |
| 139 | @setCold(true); | | |
| 140 | log(.emerg, scope, format, args); | | |
| 141 | } | | |
| 142 | | | |
| 143 | /// Log an alert message. This log level is intended to be used for | | |
| 144 | /// conditions that should be corrected immediately (e.g. database corruption). | | |
| 145 | pub fn alert( | | |
| 146 | comptime scope: @Type(.EnumLiteral), | | |
| 147 | comptime format: []const u8, | | |
| 148 | args: anytype, | | |
| 149 | ) void { | | |
| 150 | @setCold(true); | | |
| 151 | log(.alert, scope, format, args); | | |
| 152 | } | | |
| 153 | | | |
| 154 | /// Log a critical message. This log level is intended to be used | | |
| 155 | /// when a bug has been detected or something has gone wrong and it will have | | |
| 156 | /// an effect on the operation of the program. | | |
| 157 | pub fn crit( | | |
| 158 | comptime scope: @Type(.EnumLiteral), | | |
| 159 | comptime format: []const u8, | | |
| 160 | args: anytype, | | |
| 161 | ) void { | | |
| 162 | @setCold(true); | | |
| 163 | log(.crit, scope, format, args); | | |
| 164 | } | | |
| 165 | | | |
| 166 | /// Log an error message. This log level is intended to be used when | | |
| 167 | /// a bug has been detected or something has gone wrong but it is recoverable. | | |
| 168 | pub fn err( | | |
| 169 | comptime scope: @Type(.EnumLiteral), | | |
| 170 | comptime format: []const u8, | | |
| 171 | args: anytype, | | |
| 172 | ) void { | | |
| 173 | @setCold(true); | | |
| 174 | log(.err, scope, format, args); | | |
| 175 | } | | |
| 176 | | | |
| 177 | /// Log a warning message. This log level is intended to be used if | | |
| 178 | /// it is uncertain whether something has gone wrong or not, but the | | |
| 179 | /// circumstances would be worth investigating. | | |
| 180 | pub fn warn( | | |
| 181 | comptime scope: @Type(.EnumLiteral), | | |
| 182 | comptime format: []const u8, | | |
| 183 | args: anytype, | | |
| 184 | ) void { | | |
| 185 | log(.warn, scope, format, args); | | |
| 186 | } | | |
| 187 | | | |
| 188 | /// Log a notice message. This log level is intended to be used for | | |
| 189 | /// non-error but significant conditions. | | |
| 190 | pub fn notice( | | |
| 191 | comptime scope: @Type(.EnumLiteral), | | |
| 192 | comptime format: []const u8, | | |
| 193 | args: anytype, | | |
| 194 | ) void { | | |
| 195 | log(.notice, scope, format, args); | | |
| 196 | } | | |
| 197 | | | |
| 198 | /// Log an info message. This log level is intended to be used for | | |
| 199 | /// general messages about the state of the program. | | |
| 200 | pub fn info( | | |
| 201 | comptime scope: @Type(.EnumLiteral), | | |
| 202 | comptime format: []const u8, | | |
| 203 | args: anytype, | | |
| 204 | ) void { | | |
| 205 | log(.info, scope, format, args); | | |
| 206 | } | | |
| 207 | | | |
| 208 | /// Log a debug message. This log level is intended to be used for | | |
| 209 | /// messages which are only useful for debugging. | | |
| 210 | pub fn debug( | | |
| 211 | comptime scope: @Type(.EnumLiteral), | | |
| 212 | comptime format: []const u8, | | |
| 213 | args: anytype, | | |
| 214 | ) void { | | |
| 215 | log(.debug, scope, format, args); | | |
| 216 | } | | |
| 217 | | | |
| 218 | /// Returns a scoped logging namespace that logs all messages using the scope | 132 | /// Returns a scoped logging namespace that logs all messages using the scope |
| 219 | /// provided here. | 133 | /// provided here. |
| 220 | pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { | 134 | pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { |
| ... | @@ -301,3 +215,40 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { | ... | @@ -301,3 +215,40 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type { |
| 301 | | 215 | |
| 302 | /// The default scoped logging namespace. | 216 | /// The default scoped logging namespace. |
| 303 | pub const default = scoped(.default); | 217 | pub const default = scoped(.default); |
| | 218 | |
| | 219 | /// Log an emergency message using the default scope. This log level is |
| | 220 | /// intended to be used for conditions that cannot be handled and is usually |
| | 221 | /// followed by a panic. |
| | 222 | pub const emerg = default.emerg; |
| | 223 | |
| | 224 | /// Log an alert message using the default scope. This log level is intended to |
| | 225 | /// be used for conditions that should be corrected immediately (e.g. database |
| | 226 | /// corruption). |
| | 227 | pub const alert = default.alert; |
| | 228 | |
| | 229 | /// Log a critical message using the default scope. This log level is intended |
| | 230 | /// to be used when a bug has been detected or something has gone wrong and it |
| | 231 | /// will have an effect on the operation of the program. |
| | 232 | pub const crit = default.crit; |
| | 233 | |
| | 234 | /// Log an error message using the default scope. This log level is intended to |
| | 235 | /// be used when a bug has been detected or something has gone wrong but it is |
| | 236 | /// recoverable. |
| | 237 | pub const err = default.err; |
| | 238 | |
| | 239 | /// Log a warning message using the default scope. This log level is intended |
| | 240 | /// to be used if it is uncertain whether something has gone wrong or not, but |
| | 241 | /// the circumstances would be worth investigating. |
| | 242 | pub const warn = default.warn; |
| | 243 | |
| | 244 | /// Log a notice message using the default scope. This log level is intended to |
| | 245 | /// be used for non-error but significant conditions. |
| | 246 | pub const notice = default.notice; |
| | 247 | |
| | 248 | /// Log an info message using the default scope. This log level is intended to |
| | 249 | /// be used for general messages about the state of the program. |
| | 250 | pub const info = default.info; |
| | 251 | |
| | 252 | /// Log a debug message using the default scope. This log level is intended to |
| | 253 | /// be used for messages which are only useful for debugging. |
| | 254 | pub const debug = default.debug; |