Skip to content

Conversation

Logikable
Copy link
Contributor

We'd like to subscribe to only the most critical logs. Currently, there is no way to specify a log level threshold. This PR provides a stopgap solution.

In addition to the log_streams vector that new log sinks can push to, this PR adds a log_warning_streams vector that behaves similarly, but ostreams in this new vector only receive warning and error logs.

@mikesinouye
Copy link
Contributor

Hey @widlarizer, please take a look when you get a chance, thank you!

@widlarizer
Copy link
Collaborator

Seems like ERROR is predefined somewhere in Windows specific headers. You can rename the enum variand or #ifdef #undef it

@Logikable
Copy link
Contributor Author

Renamed, thanks :)

@widlarizer
Copy link
Collaborator

I'm in favor of the LogSeverity struct and an overloaded log function seems like a decent way to safely retrofit it. Is there an intended followup that exposes log_warning_streams somehow? As a side note, please take care to respect established whitespace, C++ is indented with tabs

@widlarizer widlarizer added the needs-info Issue needs more context/information in order to be resolved label Sep 9, 2025
@Logikable
Copy link
Contributor Author

I've rewritten this PR in light of the log changes by @rocallahan. One notable consequence of this PR is that log_formatted_warning and log_error_with_prefix now call log_formatted_string instead of log. I've also switched to tabs.

Regarding the last comment (@widlarizer): log_warning_streams is already exposed the same way log_streams is exposed. Today, to subscribe a sink, you append an ostream to the global Yosys::log_streams; the same can be done with log_warning_streams.

Copy link
Collaborator

@widlarizer widlarizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no code in this PR appending to log_warning_streams

@widlarizer
Copy link
Collaborator

Also, this breaks tests/various/logger_cmd_error.sh

@Logikable
Copy link
Contributor Author

Sorry -- I misunderstood. We'll be appending to log_warning_streams in a downstream change. I felt it better to contribute the public parts of our change upstream; is that ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info Issue needs more context/information in order to be resolved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants