authorgravatar for heidezomp@protonmail.comheidezomp <heidezomp@protonmail.com> 2020-08-13 16:50:38+02:00
committergravatar for heidezomp@protonmail.comheidezomp <heidezomp@protonmail.com> 2020-08-13 16:50:38+02:00
loga8e0f667c64bc6413a2c10ac76cd4e3000ceaf1b
tree02041d85daee749864a68fe3e9a513a09d926928
parent3e2e6baee568b0fb9d019fc53974aad30386b824

std.log: (breaking) remove scope parameter from logging functions

The logging functions in std.log don't take a scope parameter anymore, but use the .default scope. To provide your own scope, use the logging functions in std.log.scoped(.some_other_scope). As per nmichaels' suggestion: https://github.com/ziglang/zig/pull/6039#issuecomment-673148971

1 files changed, 37 insertions(+), 86 deletions(-)

lib/std/log.zig+37-86
......@@ -129,92 +129,6 @@ fn log(
129129 }
130130}
131131
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.
134pub 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).
145pub 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.
157pub 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.
168pub 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.
180pub 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.
190pub 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.
200pub 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.
210pub 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
218132/// Returns a scoped logging namespace that logs all messages using the scope
219133/// provided here.
220134pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
......@@ -301,3 +215,40 @@ pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
301215
302216/// The default scoped logging namespace.
303217pub 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.
222pub 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).
227pub 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.
232pub 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.
237pub 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.
242pub 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.
246pub 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.
250pub 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.
254pub const debug = default.debug;