-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
libc/stdout: add an option to redirect standard output stream to syslog #14923
Open
anchao
wants to merge
1
commit into
apache:master
Choose a base branch
from
anchao:24112501
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+52
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,5 +407,25 @@ config SYSLOG_REGISTER | |
---help--- | ||
This option will support register the syslog channel dynamically. | ||
|
||
config SYSLOG_STDOUT | ||
bool "Redirect standard output stream of printf() and vprintf() to syslog" | ||
default n | ||
---help--- | ||
Redirect standard output stream of printf(), vprintf(), puts(), putchar() to syslog, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. standard output is not a per-function entity. |
||
This option will ensure the printing sequence of syslog/printf to avoid | ||
confusion. Noted that if enable this option, the redirection | ||
capability of standard input(<) and output(>) will not be work as expect in | ||
(nsh)nuttx shell. | ||
|
||
if SYSLOG_STDOUT | ||
|
||
config SYSLOG_STDOUT_PREFIX | ||
bool "Redirect standard output stream with syslog prefix" | ||
default n | ||
---help--- | ||
Redirect standard output stream with syslog prefix. | ||
|
||
endif # SYSLOG_STDOUT | ||
|
||
endif # SYSLOG | ||
endmenu # System logging |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
but why not enable CONFIG_CONSOLE_SYSLOG? which just do what you want but in an elegant way.
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.
I also need support input from console. It seems CONSOLE_SYSLOG only support output to syslog.
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.
honestly speaking, i don't think it makes much sense to have a kconfig for this specific exotic configuration.
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.
So, do you have a better solution? The current implementation minimizes the impact for framework changes.
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.
well, i don't understand what problem you want to solve.
your description only says "avoid confusion."
if the problem is that your application is using syslog and printf in a way which somehow confuses you,
the most straightforward solution would be to fix your application.
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.
what kind of "the integrity of printing" are you talking about?
after all, syslog and stdout are two separate streams.
i suspect you are expecting too much.
are you saying that my guess is correct? ie. it's a problem in your application.
it affects developers by complicating the configuration matrix.
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.
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.
depending on the problem you want to solve, (i'm not sure what it is yet)
writing a character device driver for
/dev/console
can be a less intrusive (and IMO less confusing) solution i guess.as @xiaoxiang781216 pointed out, it can be similar to what
CONFIG_CONSOLE_SYSLOG
does.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.
maybe the problem is obvious for many developers as you say.
but it isn't for me.
can you please give me a reference?
i suggested to fix your application if it's a problem in your application.
you answered it's unrealistic to fix the application.
so i thought you were implying that the premise (it's a problem in your application) was true.
sorry, i don't understand what you mean here. what are two issues?
maybe. sorry for affecting you.
however, the confusion this PR would introduce is in another level, IMO.
applications usually do not expect
fputs(stdout)
andputs
works so differently.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.
other possible solutions i can think of are
#define printf(...) something-with-syslog
when building your application