Skip to content

Should std.log be used in the library? #59

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
natecraddock opened this issue Feb 7, 2024 · 2 comments
Open

Should std.log be used in the library? #59

natecraddock opened this issue Feb 7, 2024 · 2 comments

Comments

@natecraddock
Copy link
Owner

See this discussion: #55 (comment)

@VisenDev
Copy link
Contributor

VisenDev commented Feb 7, 2024

My motivation for this is I think at a bare minimum we should be able to tell the user why something fails. If parsing fails, I think it should have a way to tell the user where it failed and why.

Relevant ziglang/zig#17995

This is how std.json does this I believe
https://ziglang.org/documentation/master/std/#A;std:json.Diagnostics

I added logging as a simple way to achieve this functionality, since I hadn't looked into adding more complete diagnostics functionality yet

Perhaps we could look into replicating some of the functionality from std.json?

@nurpax
Copy link
Contributor

nurpax commented Apr 23, 2025

I'd be a bit against logging by default from library code. At least there must be a way to turn it off. (Or preferably it should be off by default).

I think a motivating use-case where logging is undesirable is where someone is building a console application (f.ex. something like pandoc) using Ziglua. If the inputs to the application fail, it should be the application printing an error message and there should be no errors logged from Ziglua in this case.

The diagnostics pattern in Zig is good though. But I don't think that's logging anything using std.log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants