8000 Log: remove additional newlines due to Zig's default log fn by QSmally · Pull Request #168 · zigzap/zap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Log: remove additional newlines due to Zig's default log fn #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter 8000

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions examples/bindataformpost/bindataformpost.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Handler = struct {
};

if (r.body) |body| {
std.log.info("Body length is {any}\n", .{body.len});
std.log.info("Body length is {any}", .{body.len});
}

// parse potential query params (for ?terminate=true)
Expand All @@ -43,17 +43,17 @@ const Handler = struct {
for (params.items) |kv| {
if (kv.value) |v| {
std.debug.print("\n", .{});
std.log.info("Param `{s}` in owned list is {any}\n", .{ kv.key, v });
std.log.info("Param `{s}` in owned list is {any}", .{ kv.key, v });
switch (v) {
// single-file upload
zap.Request.HttpParam.Hash_Binfile => |*file| {
const filename = file.filename orelse "(no filename)";
const mimetype = file.mimetype orelse "(no mimetype)";
const data = file.data orelse "";

std.log.debug(" filename: `{s}`\n", .{filename});
std.log.debug(" mimetype: {s}\n", .{mimetype});
std.log.debug(" contents: {any}\n", .{data});
std.log.debug(" filename: `{s}`", .{filename});
std.log.debug(" mimetype: {s}", .{mimetype});
std.log.debug(" contents: {any}", .{data});
},
// multi-file upload
zap.Request.HttpParam.Array_Binfile => |*files| {
Expand All @@ -62,9 +62,9 @@ const Handler = struct {
const mimetype = file.mimetype orelse "(no mimetype)";
const data = file.data orelse "";

std.log.debug(" filename: `{s}`\n", .{filename});
std.log.debug(" mimetype: {s}\n", .{mimetype});
std.log.debug(" contents: {any}\n", .{data});
std.log.debug(" filename: `{s}`", .{filename});
std.log.debug(" mimetype: {s}", .{mimetype});
std.log.debug(" contents: {any}", .{data});
}
files.*.deinit();
},
Expand All @@ -79,7 +79,7 @@ const Handler = struct {

// check if we received a terminate=true parameter
if (r.getParamSlice("terminate")) |str| {
std.log.info("?terminate={s}\n", .{str});
std.log.info("?terminate={s}", .{str});
if (std.mem.eql(u8, str, "true")) {
zap.stop();
}
Expand Down Expand Up @@ -110,9 +110,9 @@ pub fn main() !void {
);

try listener.listen();
std.log.info("\n\nURL is http://localhost:3000\n", .{});
std.log.info("\ncurl -v --request POST -F img=@test012345.bin http://127.0.0.1:3000\n", .{});
std.log.info("\n\nTerminate with CTRL+C or by sending query param terminate=true\n", .{});
std.log.info("\n\nURL is http://localhost:3000", .{});
std.log.info("\ncurl -v --request POST -F img=@test012345.bin http://127.0.0.1:3000", .{});
std.log.info("\n\nTerminate with CTRL+C or by sending query param terminate=true", .{});

zap.start(.{
.threads = 1,
Expand Down
8 changes: 4 additions & 4 deletions examples/cookies/cookies.zig
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ pub fn main() !void {
std.log.info("Cookie ZIG_ZAP not found!", .{});
}
} else |err| {
std.log.err("ERROR!\n", .{});
std.log.err("cannot check for `ZIG_ZAP` cookie: {any}\n", .{err});
std.log.err("ERROR!", .{});
std.log.err("cannot check for `ZIG_ZAP` cookie: {any}", .{err});
}

r.setCookie(.{
Expand All @@ -101,8 +101,8 @@ pub fn main() !void {
//
// check out other params: domain, path, secure, http_only
}) catch |err| {
std.log.err("ERROR!\n", .{});
std.log.err("cannot set cookie: {any}\n", .{err});
std.log.err("ERROR!", .{});
std.log.err("cannot set cookie: {any}", .{err});
};

r.sendBody("Hello") catch unreachable;
Expand Down
2 changes: 1 addition & 1 deletion examples/endpoint/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ pub fn main() !void {

// show potential memory leaks when ZAP is shut down
const has_leaked = gpa.detectLeaks();
std.log.debug("Has leaked: {}\n", .{has_leaked});
std.log.debug("Has leaked: {}", .{has_leaked});
}
4 changes: 2 additions & 2 deletions examples/http_params/http_params.zig
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn main() !void {
std.log.info("Param one not found!", .{});
}
} else |err| {
std.log.err("cannot check for `one` param: {any}\n", .{err});
std.log.err("cannot check for `one` param: {any}", .{err});
}

// check if we received a terminate=true parameter
Expand All @@ -137,7 +137,7 @@ pub fn main() !void {
);

try listener.listen();
std.log.info("\n\nTerminate with CTRL+C or by sending query param terminate=true\n", .{});
std.log.info("\n\nTerminate with CTRL+C or by sending query param terminate=true", .{});

const thread = try makeRequestThread(allocator, "http://127.0.0.1:3000/?>
defer thread.join();
Expand Down
4 changes: 2 additions & 2 deletions src/http_auth.zig
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ pub fn UserPassSession(comptime Lookup: type, comptime lockedPwLookups: bool) ty
.value = "invalid",
.max_age_s = -1,
})) {
zap.debug("logout ok\n", .{});
zap.debug("logout ok", .{});
} else |err| {
zap.debug("logout cookie setting failed: {any}\n", .{err});
zap.debug("logout cookie setting failed: {any}", .{err});
}

r.parseCookies(false);
Expand Down
16 changes: 8 additions & 8 deletions src/request.zig
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,24 @@ fn parseBinfilesFrom(a: Allocator, o: fio.FIOBJ) !HttpParam {
fio.FIOBJ_T_DATA => {
if (fio.is_invalid(data) == 1) {
data_slice = "(zap: invalid data)";
zap.log.warn("HTTP param binary file is not a data object\n", .{});
zap.log.warn("HTTP param binary file is not a data object", .{});
} else {
// the data
const data_len = fio.fiobj_data_len(data);
var data_buf = fio.fiobj_data_read(data, data_len);

if (data_len < 0) {
zap.log.warn("HTTP param binary file size negative: {d}\n", .{data_len});
zap.log.warn("FIOBJ_TYPE of data is: {d}\n", .{fio.fiobj_type(data)});
zap.log.warn("HTTP param binary file size negative: {d}", .{data_len});
zap.log.warn("FIOBJ_TYPE of data is: {d}", .{fio.fiobj_type(data)});
} else {
if (data_buf.len != data_len) {
zap.log.warn("HTTP param binary file size mismatch: should {d}, is: {d}\n", .{ data_len, data_buf.len });
zap.log.warn("HTTP param binary file size mismatch: should {d}, is: {d}", .{ data_len, data_buf.len });
}

if (data_buf.len > 0) {
data_slice = data_buf.data[0..data_buf.len];
} else {
zap.log.warn("HTTP param binary file buffer size negative: {d}\n", .{data_buf.len});
zap.log.warn("HTTP param binary file buffer size negative: {d}", .{data_buf.len});
data_slice = "(zap: invalid data: negative BUFFER size)";
}
}
Expand Down Expand Up @@ -379,7 +379,7 @@ pub fn setContentType(self: *const Request, c: ContentType) HttpError!void {
.JSON => "application/json",
else => "text/html",
};
zap.log.debug("setting content-type to {s}\n", .{s});
zap.log.debug("setting content-type to {s}", .{s});
return self.setHeader("content-type", s);
}

Expand Down Expand Up @@ -511,7 +511,7 @@ pub fn setHeader(self: *const Request, name: []const u8, value: []const u8) Http
// FIXME without the following if, we get errors in release builds
// at least we don't have to log unconditionally
if (ret == -1) {
zap.log.debug("***************** zap.zig:274\n", .{});
zap.log.debug("***************** zap.zig:274", .{});
}

if (ret == 0) return;
Expand Down Expand Up @@ -680,7 +680,7 @@ pub fn setCookie(self: *const Request, args: CookieArgs) HttpError!void {
// TODO: still happening?
const ret = fio.http_set_cookie(self.h, c);
if (ret == -1) {
zap.log.err("fio.http_set_cookie returned: {}\n", .{ret});
zap.log.err("fio.http_set_cookie returned: {}", .{ret});
return error.SetCookie;
}
}
Expand Down
0