forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Features: - Adds macros like `info!` (with newline) and `pr_info!` (without newline) for the usual levels that the kernel support. - Includes the "continuation" level. - Includes automatically the module name in the string. - Includes, hopefully, pretty detailed logs. - Includes aliases to make it even easier to find the equivalent to `println!` for newcomers. Implementation: - Stack usage should be 1 KiB at most, regardless of the number of invocations of the macro in a single function. This should make it possible to use even when optimizations are not enabled. See code comments for the details. - The formatting string is compile-time, shared as a `static`, and always the same. We could perhaps pre-generate them per-module to avoid another `%.*s` in `printk()`, but I don't think it is worth the complexity at the moment, and it would increase memory usage anyway. Naming: - The `pr_*` names are the same as the kernel ones, and behave similarly, i.e. no newline at the end. - The non-`pr_*` ones are the same but without the prefix. They look better (shorter, no underscore), have the newline like `println!`, and they are what people should almost always use except if they need continuation. And they look pretty similar to the Rust `log` crate ones, too! - I think we can afford these short names (in the prelude, even!) since this is new code and nobody should be defining macros in the kernel with such short names, ever! Future: - I will open an issue with a few things that can be added on top, similar to the kernel parameters feature. - When we have tidy support (or custom clippy lints), we can add one to find the pattern: pr_*("...\n", ...); and suggest the non-prefixed, non-newline version instead: *("...", "..."); Signed-off-by: Miguel Ojeda <[email protected]>
- Loading branch information
Showing
25 changed files
with
965 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.