Fix issue with trying to call detail::enable_virtual_terminal_processing_if_needed unconditionally on print
This commit is contained in:
parent
ab2d440a00
commit
a3e3916daa
@ -167,7 +167,11 @@ namespace cpptrace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void stacktrace::print(std::ostream& stream, bool color, bool newline_at_end, const char* header) const {
|
void stacktrace::print(std::ostream& stream, bool color, bool newline_at_end, const char* header) const {
|
||||||
if(color) {
|
if(
|
||||||
|
color && (
|
||||||
|
(&stream == &std::cout && isatty(stdout_fileno)) || (&stream == &std::cerr && isatty(stderr_fileno))
|
||||||
|
)
|
||||||
|
) {
|
||||||
detail::enable_virtual_terminal_processing_if_needed();
|
detail::enable_virtual_terminal_processing_if_needed();
|
||||||
}
|
}
|
||||||
stream<<(header ? header : "Stack trace (most recent call first):")<<std::endl;
|
stream<<(header ? header : "Stack trace (most recent call first):")<<std::endl;
|
||||||
|
|||||||
@ -300,7 +300,12 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ctrace_stacktrace_print(const ctrace_stacktrace* trace, FILE* to, ctrace_bool use_color) {
|
void ctrace_stacktrace_print(const ctrace_stacktrace* trace, FILE* to, ctrace_bool use_color) {
|
||||||
if(use_color) cpptrace::detail::enable_virtual_terminal_processing_if_needed();
|
if(
|
||||||
|
use_color && (
|
||||||
|
(to == stdout && cpptrace::isatty(cpptrace::stdout_fileno)) ||
|
||||||
|
(to == stderr && cpptrace::isatty(cpptrace::stderr_fileno))
|
||||||
|
)
|
||||||
|
) cpptrace::detail::enable_virtual_terminal_processing_if_needed();
|
||||||
ctrace::ffprintf(to, "Stack trace (most recent call first):\n");
|
ctrace::ffprintf(to, "Stack trace (most recent call first):\n");
|
||||||
if(trace->count == 0 || !trace->frames) {
|
if(trace->count == 0 || !trace->frames) {
|
||||||
ctrace::ffprintf(to, "<empty trace>\n");
|
ctrace::ffprintf(to, "<empty trace>\n");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user