remove extra newlines from log calls
This commit is contained in:
parent
43dad638f2
commit
0f6ac055a4
9 changed files with 46 additions and 46 deletions
|
@ -19,7 +19,7 @@ pub fn magicValid(magic: []const u8) !void {
|
|||
}
|
||||
|
||||
if (!valid) {
|
||||
log.debug("\tINVALID HEADER: '{s}'\n", .{magic});
|
||||
log.debug("\tINVALID HEADER: '{s}'", .{magic});
|
||||
return BMPValidError.InvalidMagic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ pub const Embed = struct {
|
|||
|
||||
if (read_bytes < 0) {
|
||||
const st: i32 = c.sf_error(self.sndfile);
|
||||
log.debug("Failed to read {s} ({s})\n", .{
|
||||
log.debug("Failed to read {s} ({s})", .{
|
||||
self.filepath,
|
||||
c.sf_error_number(st),
|
||||
});
|
||||
|
|
|
@ -33,7 +33,7 @@ pub fn sopen(
|
|||
const st: i32 = c.sf_error(file);
|
||||
|
||||
if (st != 0) {
|
||||
log.debug("Failed to open {s} ({s})\n", .{
|
||||
log.debug("Failed to open {s} ({s})", .{
|
||||
path,
|
||||
c.sf_error_number(st),
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ pub fn sopen(
|
|||
const frames_on_end_by_end = c.sf_seek(file, frames_on_end, c.SEEK_SET);
|
||||
try std.testing.expectEqual(frames_on_end, frames_on_end_by_end);
|
||||
|
||||
log.debug("frames on end: {}, frame on end (2): {}\n", .{ frames_on_end, frames_on_end_by_end });
|
||||
log.debug("frames on end: {}, frame on end (2): {}", .{ frames_on_end, frames_on_end_by_end });
|
||||
|
||||
return file.?;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ pub fn swrite(file: *c.SNDFILE, buf: [*]f32, frames: i64) !void {
|
|||
const count = c.sf_writef_float(file, buf, frames);
|
||||
|
||||
if (count != frames) {
|
||||
log.debug("Wanted to write {}, got {}\n", .{ frames, count });
|
||||
log.debug("Wanted to write {}, got {}", .{ frames, count });
|
||||
return ImageError.WriteFail;
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ pub fn sseek(file: *c.SNDFILE, offset: usize) void {
|
|||
std.debug.assert(frames == frames_current);
|
||||
|
||||
if (frames != offset_i64) {
|
||||
log.debug("failed to seek to {} (seeked {} frames, offset_i64={})\n", .{ offset, frames, offset_i64 });
|
||||
log.debug("failed to seek to {} (seeked {} frames, offset_i64={})", .{ offset, frames, offset_i64 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ pub const Image = struct {
|
|||
pub fn close(self: *Image) void {
|
||||
var st: i32 = c.sf_close(self.sndfile);
|
||||
if (st != 0) {
|
||||
log.debug("Failed to close {s} ({s})\n", .{
|
||||
log.debug("Failed to close {s} ({s})", .{
|
||||
self.path,
|
||||
c.sf_error_number(st),
|
||||
});
|
||||
|
@ -227,7 +227,7 @@ pub const Image = struct {
|
|||
sseek(out_file, start);
|
||||
|
||||
while (i <= end) : (i += buf.len) {
|
||||
log.debug("\t\ti={d}, buf.len={d}, end={d}\n", .{ i, buf.len, end });
|
||||
log.debug("\t\ti={d}, buf.len={d}, end={d}", .{ i, buf.len, end });
|
||||
sseek(self.sndfile, i);
|
||||
sseek(out_file, i);
|
||||
|
||||
|
@ -253,7 +253,7 @@ pub const Image = struct {
|
|||
fn getSeekPos(self: *Image, position: plugins.Position) plugins.SeekPos {
|
||||
const file_end = self.frames;
|
||||
var seek_pos = position.seekPos(file_end);
|
||||
log.debug("\tstart {d} end {d}\n", .{ seek_pos.start, seek_pos.end });
|
||||
log.debug("\tstart {d} end {d}", .{ seek_pos.start, seek_pos.end });
|
||||
return seek_pos;
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ pub const Image = struct {
|
|||
self.curpath = path;
|
||||
self.frames = @intCast(usize, in_fmt.frames);
|
||||
|
||||
log.debug("\timage: reopened on '{s}' (frames={d}, fmt.frames={d})\n", .{
|
||||
log.debug("\timage: reopened on '{s}' (frames={d}, fmt.frames={d})", .{
|
||||
self.curpath,
|
||||
self.frames,
|
||||
in_fmt.frames,
|
||||
|
@ -309,12 +309,12 @@ pub const Image = struct {
|
|||
defer ctx.allocator.free(ports);
|
||||
|
||||
if (ctx.n_audio_in > 2) {
|
||||
log.debug("plugin <{s}> has more than two inputs.\n", .{plugin_uri});
|
||||
log.debug("plugin <{s}> has more than two inputs.", .{plugin_uri});
|
||||
return ImageError.InvalidPlugin;
|
||||
}
|
||||
|
||||
if (ctx.n_audio_out > 2) {
|
||||
log.debug("plugin <{s}> has more than two outputs.\n", .{plugin_uri});
|
||||
log.debug("plugin <{s}> has more than two outputs.", .{plugin_uri});
|
||||
return ImageError.InvalidPlugin;
|
||||
}
|
||||
|
||||
|
@ -326,14 +326,14 @@ pub const Image = struct {
|
|||
|
||||
var sym = c.lilv_new_string(ctx.world, sym_cstr.ptr);
|
||||
const port = c.lilv_plugin_get_port_by_symbol(ctx.plugin, sym) orelse {
|
||||
log.debug("assert fail: symbol {s} not found on port\n", .{param.sym});
|
||||
log.debug("assert fail: symbol {s} not found on port", .{param.sym});
|
||||
return ImageError.InvalidSymbol;
|
||||
};
|
||||
|
||||
c.lilv_node_free(sym);
|
||||
|
||||
var idx = c.lilv_port_get_index(ctx.plugin, port);
|
||||
log.debug("\tset sym={s}, idx={d} to val={}\n", .{
|
||||
log.debug("\tset sym={s}, idx={d} to val={}", .{
|
||||
param.sym,
|
||||
idx,
|
||||
param.value,
|
||||
|
@ -344,7 +344,7 @@ pub const Image = struct {
|
|||
// now we need to generate a temporary file and put the output of
|
||||
// running the plugin on that file
|
||||
var tmpnam = try temporaryName(self.allocator);
|
||||
log.debug("\trunning plugin from '{s}' to '{s}'\n", .{ self.curpath, tmpnam });
|
||||
log.debug("\trunning plugin from '{s}' to '{s}'", .{ self.curpath, tmpnam });
|
||||
|
||||
var out_fmt = mkSfInfo();
|
||||
var out_file = try sopen(self.allocator, tmpnam, c.SFM_WRITE, &out_fmt);
|
||||
|
@ -377,7 +377,7 @@ pub const Image = struct {
|
|||
sseek(self.sndfile, seek_pos.start);
|
||||
|
||||
var i: usize = seek_pos.start;
|
||||
log.debug("\tseek pos start: {d} end: {d}\n", .{ seek_pos.start, seek_pos.end });
|
||||
log.debug("\tseek pos start: {d} end: {d}", .{ seek_pos.start, seek_pos.end });
|
||||
|
||||
var inbuf = &rctx.buffers.in;
|
||||
var outbuf = &rctx.buffers.out;
|
||||
|
@ -388,7 +388,7 @@ pub const Image = struct {
|
|||
|
||||
const read_bytes = c.sf_readf_float(self.sndfile, inbuf, 1);
|
||||
if (read_bytes == 0) {
|
||||
log.debug("WARN! reached EOF at idx={d}\n", .{i});
|
||||
log.debug("WARN! reached EOF at idx={d}", .{i});
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -417,11 +417,11 @@ pub const Image = struct {
|
|||
try self.checkValid();
|
||||
|
||||
var time_taken = timer.read();
|
||||
log.debug("\ttook {d:.2}ms running plugin\n", .{time_taken / std.time.us_per_ms});
|
||||
log.debug("\ttook {d:.2}ms running plugin", .{time_taken / std.time.us_per_ms});
|
||||
}
|
||||
|
||||
pub fn saveTo(self: *Image, out_path: []const u8) !void {
|
||||
log.debug("\timg: copy from '{s}' to '{s}'\n", .{ self.curpath, out_path });
|
||||
log.debug("\timg: copy from '{s}' to '{s}'", .{ self.curpath, out_path });
|
||||
try std.fs.copyFileAbsolute(self.curpath, out_path, .{});
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ pub const Image = struct {
|
|||
// the code here is a copypaste of runPlugin() without the specific
|
||||
// lilv things.
|
||||
var tmpnam = try temporaryName(self.allocator);
|
||||
log.debug("\trunning CUSTOM plugin from '{s}' to '{s}'\n", .{ self.curpath, tmpnam });
|
||||
log.debug("\trunning CUSTOM plugin from '{s}' to '{s}'", .{ self.curpath, tmpnam });
|
||||
|
||||
var out_fmt = mkSfInfo();
|
||||
var out_file = try sopen(self.allocator, tmpnam, c.SFM_WRITE, &out_fmt);
|
||||
|
@ -476,7 +476,7 @@ pub const Image = struct {
|
|||
sseek(self.sndfile, seek_pos.start);
|
||||
|
||||
var i: usize = seek_pos.start;
|
||||
log.debug("\tseek pos start: {d} end: {d}\n", .{ seek_pos.start, seek_pos.end });
|
||||
log.debug("\tseek pos start: {d} end: {d}", .{ seek_pos.start, seek_pos.end });
|
||||
|
||||
var inbuf = &bufs.in;
|
||||
var outbuf = &bufs.out;
|
||||
|
@ -484,7 +484,7 @@ pub const Image = struct {
|
|||
while (i <= seek_pos.end) : (i += 1) {
|
||||
const read_bytes = c.sf_readf_float(self.sndfile, inbuf, 1);
|
||||
if (read_bytes == 0) {
|
||||
log.debug("WARN! reached EOF at idx={d}\n", .{i});
|
||||
log.debug("WARN! reached EOF at idx={d}", .{i});
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ pub const Command = struct {
|
|||
}
|
||||
|
||||
pub fn print(base: *const @This()) void {
|
||||
log.debug("tag: {}\n", .{base.tag});
|
||||
log.debug("tag: {}", .{base.tag});
|
||||
}
|
||||
|
||||
pub const Noop = struct {
|
||||
|
@ -531,7 +531,6 @@ pub const Lang = struct {
|
|||
fn doError(self: *Lang, comptime fmt: []const u8, args: anytype) void {
|
||||
log.warn("ERROR! at line {}: ", .{self.line});
|
||||
log.warn(fmt, args);
|
||||
log.warn("\n", .{});
|
||||
self.has_error = true;
|
||||
}
|
||||
|
||||
|
@ -610,7 +609,7 @@ pub const Lang = struct {
|
|||
else => @compileError("Invalid parameter type (" ++ @typeName(cmd_field.field_type) ++ ") left on command struct " ++ @typeName(command_struct) ++ "."),
|
||||
};
|
||||
|
||||
log.debug("parsing {s}, arg of type {s} => {any}\n", .{
|
||||
log.debug("parsing {s}, arg of type {s} => {any}", .{
|
||||
@typeName(command_struct),
|
||||
@typeName(@TypeOf(argument_value)),
|
||||
argument_value,
|
||||
|
@ -622,7 +621,7 @@ pub const Lang = struct {
|
|||
|
||||
cmd.base.tag = command_struct.base_tag;
|
||||
const command = cmd.base.cast(command_struct).?;
|
||||
log.debug("cmd: {}\n", .{command});
|
||||
log.debug("cmd: {}", .{command});
|
||||
}
|
||||
|
||||
pub fn parse(self: *Lang, data: []const u8) !CommandList {
|
||||
|
|
|
@ -120,7 +120,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port {
|
|||
if (c.lilv_port_is_a(ctx.plugin, lport, lv2_InputPort)) {
|
||||
port.is_input = true;
|
||||
} else if (!c.lilv_port_is_a(ctx.plugin, lport, lv2_OutputPort) and !port.optional) {
|
||||
log.debug("Port {d} is neither input or output\n", .{i});
|
||||
log.debug("Port {d} is neither input or output", .{i});
|
||||
return error.UnassignedIOPort;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port {
|
|||
ctx.n_audio_out += 1;
|
||||
}
|
||||
} else if (!port.optional) {
|
||||
log.debug("Port {d} has unsupported type\n", .{i});
|
||||
log.debug("Port {d} has unsupported type", .{i});
|
||||
return error.UnsupportedPortType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ fn magickLoad(image: *Image) !MagickContext {
|
|||
var curpath = try std.cstr.addNullByte(image.allocator, image.curpath);
|
||||
defer image.allocator.free(curpath);
|
||||
|
||||
log.debug("loading '{s}'\n", .{curpath});
|
||||
log.debug("loading '{s}'", .{curpath});
|
||||
|
||||
if (mc.MagickReadImage(mctx.wand, curpath.ptr) != 1)
|
||||
return error.MagickReadFail;
|
||||
|
@ -61,7 +61,7 @@ fn magickSave(image: *Image, wand: *mc.MagickWand) !void {
|
|||
if (mc.MagickWriteImage(wand, c_tmpnam.ptr) != 1)
|
||||
return error.MagickWriteFail;
|
||||
|
||||
log.debug("OK\n", .{});
|
||||
log.debug("OK", .{});
|
||||
|
||||
try image.reopen(tmpnam);
|
||||
}
|
||||
|
|
16
src/main.zig
16
src/main.zig
|
@ -134,7 +134,7 @@ pub fn doRepl(allocator: std.mem.Allocator, args_it: anytype) !void {
|
|||
|
||||
var rd_line = readline.readline("> ");
|
||||
if (rd_line == null) {
|
||||
log.debug("leaving from eof\n", .{});
|
||||
log.debug("leaving from eof", .{});
|
||||
break;
|
||||
}
|
||||
readline.add_history(rd_line);
|
||||
|
@ -202,14 +202,14 @@ pub fn doRepl(allocator: std.mem.Allocator, args_it: anytype) !void {
|
|||
try printer.printList(cmds, stream);
|
||||
continue;
|
||||
} else if (std.mem.eql(u8, line, "quit") or std.mem.eql(u8, line, "q")) {
|
||||
log.debug("leaving\n", .{});
|
||||
log.debug("leaving", .{});
|
||||
break;
|
||||
} else if (std.mem.startsWith(u8, line, "#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var cmds_parsed = lang.parse(line) catch |err| {
|
||||
log.debug("repl: error while parsing: {}\n", .{err});
|
||||
log.debug("repl: error while parsing: {}", .{err});
|
||||
continue;
|
||||
};
|
||||
|
||||
|
@ -233,10 +233,10 @@ pub fn doRepl(allocator: std.mem.Allocator, args_it: anytype) !void {
|
|||
}
|
||||
|
||||
fn doHelp() void {
|
||||
log.debug("scritcher!\n", .{});
|
||||
log.debug("usage: scritcher [run|help|repl]\n", .{});
|
||||
log.debug("\tscritcher run path_to_script.scri path_to_input_file.bmp\n", .{});
|
||||
log.debug("\tscritcher repl path_to_script.scri path_to_input_file.bmp\n", .{});
|
||||
log.debug("scritcher!", .{});
|
||||
log.debug("usage: scritcher [run|help|repl]", .{});
|
||||
log.debug("\tscritcher run path_to_script.scri path_to_input_file.bmp", .{});
|
||||
log.debug("\tscritcher repl path_to_script.scri path_to_input_file.bmp", .{});
|
||||
}
|
||||
|
||||
fn doRun(allocator: std.mem.Allocator, args_it: anytype) !void {
|
||||
|
@ -289,7 +289,7 @@ pub fn main() !void {
|
|||
} else if (std.mem.eql(u8, cli_command, "run")) {
|
||||
return try doRun(allocator, &args_it);
|
||||
} else {
|
||||
log.debug("unknown command: '{s}'\n", .{cli_command});
|
||||
log.debug("unknown command: '{s}'", .{cli_command});
|
||||
return error.UnknownCommand;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ pub fn makeContext(allocator: std.mem.Allocator, plugin_uri: []const u8) !Contex
|
|||
c.lilv_world_load_all(world);
|
||||
|
||||
var uri: *c.LilvNode = c.lilv_new_uri(world, cstr_plugin_uri.ptr) orelse {
|
||||
log.debug("Invalid plugin URI <{s}>\n", .{plugin_uri});
|
||||
log.debug("Invalid plugin URI <{s}>", .{plugin_uri});
|
||||
return ImageError.InvalidPlugin;
|
||||
};
|
||||
defer c.lilv_node_free(uri);
|
||||
|
@ -148,7 +148,7 @@ pub fn makeContext(allocator: std.mem.Allocator, plugin_uri: []const u8) !Contex
|
|||
const plugins: *const c.LilvPlugins = c.lilv_world_get_all_plugins(world).?;
|
||||
|
||||
var plugin: *const c.LilvPlugin = c.lilv_plugins_get_by_uri(plugins, uri) orelse {
|
||||
log.debug("Plugin <{s}> not found\n", .{plugin_uri});
|
||||
log.debug("Plugin <{s}> not found", .{plugin_uri});
|
||||
return ImageError.UnknownPlugin;
|
||||
};
|
||||
|
||||
|
|
|
@ -71,9 +71,10 @@ pub const Runner = struct {
|
|||
if (self.repl) index += 3 else index += 3;
|
||||
|
||||
for (self.args) |arg, idx| {
|
||||
log.debug("arg{d} = {s}\n", .{ idx, arg });
|
||||
log.debug("arg{d} = {s}", .{ idx, arg });
|
||||
}
|
||||
log.debug("fetch arg idx={d}, val={s}\n", .{ index, self.args[index] });
|
||||
log.debug("fetch arg idx={d}", .{index});
|
||||
log.debug("fetch arg val={s}", .{self.args[index]});
|
||||
return self.args[index];
|
||||
} else {
|
||||
return load_path;
|
||||
|
@ -93,7 +94,7 @@ pub const Runner = struct {
|
|||
|
||||
fn loadCmd(self: *Runner, path_or_argidx: []const u8) !void {
|
||||
const load_path = try self.resolveArgPath(path_or_argidx);
|
||||
log.debug("\tload path: {s}\n", .{load_path});
|
||||
log.debug("\tload path: {s}", .{load_path});
|
||||
|
||||
// we could use ImageMagick to convert from X to BMP
|
||||
// but i can't find an easy way to do things in memory.
|
||||
|
@ -103,7 +104,7 @@ pub const Runner = struct {
|
|||
// krita/gimp and make it export a bmp and while in the program you can
|
||||
// apply filters, etc.
|
||||
if (!std.mem.endsWith(u8, load_path, ".bmp") and !std.mem.endsWith(u8, load_path, ".ppm")) {
|
||||
log.debug("Only BMP files are allowed to be loaded. Got path '{s}'\n", .{load_path});
|
||||
log.debug("Only BMP files are allowed to be loaded. Got path '{s}'", .{load_path});
|
||||
return RunError.NoBMP;
|
||||
}
|
||||
|
||||
|
@ -118,7 +119,7 @@ pub const Runner = struct {
|
|||
if (self.image) |image| {
|
||||
return image;
|
||||
} else {
|
||||
log.debug("image is required!\n", .{});
|
||||
log.debug("image is required!", .{});
|
||||
return RunError.ImageRequired;
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +207,7 @@ pub const Runner = struct {
|
|||
);
|
||||
//defer proc.deinit();
|
||||
|
||||
log.debug("running '{s} {s}'\n", .{ runqs.program, out_path });
|
||||
log.debug("running '{s} {s}'", .{ runqs.program, out_path });
|
||||
_ = try proc.spawnAndWait();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue