Skip to content

Commit

Permalink
[bug] fix log_color
Browse files Browse the repository at this point in the history
  • Loading branch information
jyf111 committed Aug 12, 2023
1 parent 655a715 commit 9dd6a75
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions eBPF_Supermarket/User_Function_Tracer/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ IncludeCategories:
Priority: 0
- Regex: '<getopt.h>'
Priority: -1
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 2
- Regex: '.\*'
Priority: 1
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 2
- Regex: '.\*'
Priority: 1
2 changes: 1 addition & 1 deletion eBPF_Supermarket/User_Function_Tracer/src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int debug;

void log_color(const char* color) {
char* term = getenv("TERM");
if (isatty(fileno(stdout)) && !(term && !strcmp(term, "dumb"))) {
if (isatty(fileno(stderr)) && !(term && !strcmp(term, "dumb"))) {
LOG("%s", color);
}
}
Expand Down
5 changes: 4 additions & 1 deletion eBPF_Supermarket/User_Function_Tracer/src/utrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ static int handle_event(void *ctx, void *data, size_t data_sz) {
log_time(r->duration_ns);
log_split();
log_char(' ', 2 * r->ustack_sz);
LOG("} " TERM_GRAY "/* %s */" TERM_NC "\n", stack_func[r->global_sz]);
LOG("} ");
log_color(TERM_GRAY);
LOG("/* %s */\n", stack_func[r->global_sz]);
log_color(TERM_NC);
}
pending = 0;
status = 1;
Expand Down

0 comments on commit 9dd6a75

Please sign in to comment.