toradex / vscode-torizon-templates

VS Code Torizon Integrated Development Environment Templates
MIT License
15 stars 20 forks source link

Zig Console not printing "Hello Torizon" message on debug console when trying to debug it on the board #162

Closed andreriesco closed 3 weeks ago

andreriesco commented 7 months ago

When trying to debug a zigConsole application on the board (Torizon ARMv8 debug command), the Hello Torizon message is not being printed on VSCode's Debug Console.

image

However, when using stdout.print() instead of log.info it works.

image

P.S. Local debugging (Local AMD64 debug command) works on both cases.

andreriesco commented 7 months ago

@kassane when you have some time, can you take a look on what may be the issue here, please?

kassane commented 7 months ago

Hi,

Firstly, stdout.print works because it obviously uses stdout (w/ buffer.flush).

const stdout_file = std.io.getStdOut().writer();
var bw = std.io.bufferedWriter(stdout_file);
const stdout = bw.writer();
try stdout.print("Hello toradex.\n", .{});

try bw.flush();

But std.debug.print and std.log.|info|debug|err uses stderr.

// works on release mode
pub const std_options = struct {
    pub const log_level = .info;
};

Remove this line, because pub const log_level = .debug is default.

// The default log level is based on build mode.
pub const default_level: Level = switch (builtin.mode) {
.Debug => .debug,
.ReleaseSafe => .info,
.ReleaseFast, .ReleaseSmall => .err,
};

I had forked an unofficial tutorial on how std.log works, mentioned in the PR.

andreriesco commented 7 months ago

Got it. I added on this commit the configuration on launch.json to print also the stderr. Now it is possible to see the output message. Thanks.

kassane commented 7 months ago

Amazing!!