-
Notifications
You must be signed in to change notification settings - Fork 15
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
Introduce stream support #82
base: master
Are you sure you want to change the base?
Conversation
{ | ||
m_trace.stream = stream ? stream : stdout; | ||
} | ||
void mbed_trace_fputs_function_set(int (*fputs_f)(const char *, FILE*)) |
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 we doesn’t need this API at all
//print out whole data | ||
m_trace.printf(m_trace.line); | ||
m_trace.fputs(m_trace.line, m_trace.stream); |
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.
previous puts()
was used to print line. fputs
behaviour a bit differently, but maybe we should use fwrite
instead because we know line lenght already and it could be faster, opinions? 🤔
This PR changes default "printer" function from |
Feels a little bit unnecessary. I've always been quite happy to provide a print function that does I guess a general config option to include a newline in the output call would streamline it a bit. |
BTW, In POSIX
On non-POSIX systems, the atomicity of a single library call isn't guaranteed, and we're relying on our mutex anyway. But having an option to make the formatting core stick on a |
True, basically same thing can be achieved already with a bit more code. Idea was to "simplify" output a bit so that output is always standard FILE stream so that output can be something else than stdout easily.. Do you see some (other negative) side-effects with this PR ?
I think about it also. Would be easy task.
Maybe our mutex API calls could have stream argument so it could be |
I've always thought part of the concept was that there was no assumption anywhere that the output actually be a stream - it could be an insertion into a circular buffer, or transmission as a network packet. Hence the entry being delivered as a simple single "unit". I'd kind of like that purity preserved in the core, but I guess a helper that does
|
Locking is a slightly fiddly concept - not sure You'd need one lock to protect the formatting and temp buffers in the tr_xxx calls, and a separate lock to protect interaction between buffer drain to screen and other screen users like CLI. That second lock could actually be not visible to the formatter, and built into the output function. But at the minute the CLI assumes it's all one lock, and uses the formatter lock to avoid output clash. |
Status
IN PROGRESS
Migrations
NO
Description
This allows to pipe traces to any standard
FILE*
stream.NOTE: This should not break existing API's or behaviours.
This allows to do this:
Todo