-
Notifications
You must be signed in to change notification settings - Fork 109
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
Standardize logging utility #552
Conversation
Code Review Agent Run #571ed1Actionable Suggestions - 9
Review Details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmarks
Benchmark suite | Current: 85701c4 | Previous: 9e07773 | Ratio |
---|---|---|---|
Dhrystone |
1307 Average DMIPS over 10 runs |
1330 Average DMIPS over 10 runs |
1.02 |
Coremark |
969.939 Average iterations/sec over 10 runs |
962.043 Average iterations/sec over 10 runs |
0.99 |
This comment was automatically generated by workflow using github-action-benchmark.
Changelist by BitoThis pull request implements the following key changes.
|
d8912c4
to
517c23d
Compare
Code Review Agent Run #608943Actionable Suggestions - 7
Additional Suggestions - 1
Review Details
|
517c23d
to
da1fa29
Compare
Code Review Agent Run #d67d08Actionable Suggestions - 6
Additional Suggestions - 4
Review Details
|
3c36054
to
10ca95d
Compare
Code Review Agent Run #343259Actionable Suggestions - 4
Additional Suggestions - 5
Review Details
|
10ca95d
to
5ff4fd0
Compare
Code Review Agent Run #e5b0dbActionable Suggestions - 2
Additional Suggestions - 4
Review Details
|
src/main.c
Outdated
"RV32I[MAFC] Emulator which loads an ELF file to execute.\n" | ||
"Usage: %s [options] [filename] [arguments]\n" | ||
"Options:\n" | ||
rv_log_info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message should always appear, so that INFO is not sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message should always appear, so that INFO is not sufficient.
Use TRACE instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use TRACE instead.
How about ERROR
instead? While dumping the usage, the program exits with non-zero code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use TRACE instead.
How about
ERROR
instead? While dumping the usage, the program exits with non-zero code.
I chose wrong level (TRACE) which is the lowest log level. I originally planned to choose highest log level (FATAL), but ERROR works as well, so I'll go with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the logging feature is quite useful, we can promote the functions as public APIs. That is, include log.h
in the header riscv.h
.
e759f8e
to
fee21ca
Compare
Code Review Agent Run #648fc0Actionable Suggestions - 7
Review Details
|
45839c7
to
9e07773
Compare
Code Review Agent Run #d970f8Actionable Suggestions - 4
Additional Suggestions - 1
Review Details
|
Previously, messages were printed using both printf and fprintf, causing the information to be mixed between stdout and stderr. To address this, the log.[ch] was integrated to standardize the logging. The log.[ch]'s API are encapsulated one more layer with prefix 'rv', and included in src/common.h. The logging API uses color to differentiate messages at different levels, ensuring that logging all information to the same stdout stream does not cause confusion. The color feature is controlled by ENABLE_LOG_COLOR and is enabled by default. Note that the logging stdout stream is registered during rv_remap_stdstream() as the new stdout stream could be remapped at there. Related: sysprog21#310
Since the newly introduced logging APIs generate logs during runtime, the check recipe must filter out this log information before validation. Additionally, refine the check recipe into a new target, check-test, which serves as a template to enhance readability.
9e07773
to
85701c4
Compare
Code Review Agent Run #d90a76Actionable Suggestions - 1
Additional Suggestions - 4
Review Details
|
Thank @ChinYikMing for contributing! |
Previously, messages were printed using both printf and fprintf,
causing the information to be mixed between stdout and stderr. To
address this, the log.[ch] was integrated to standardize the logging.
The log.[ch]'s API are encapsulated one more layer with prefix 'rv',
and included in src/common.h.
The logging API uses color to differentiate messages at different
levels, ensuring that logging all information to the same stdout stream
does not cause confusion. The color feature is controlled by
ENABLE_LOG_COLOR and is enabled by default.
Note that the logging stdout stream is registered during
rv_remap_stdstream() as the new stdout stream could be remapped at
there.
Since the newly introduced logging APIs generate logs during runtime,
the check recipe must filter out this log information before validation.
Additionally, refine the check recipe into a new target, check-test,
which serves as a template to enhance readability.
Summary by Bito
This PR implements a unified logging system that replaces scattered printf/fprintf calls with a standardized API supporting multiple severity levels and color-coded output. The system is integrated across the RISC-V emulator core, device emulation, and system calls, with the build system updated to handle filtered logging output and improved test recipes.Unit tests added: False
Estimated effort to review (1-5, lower is better): 5