Skip to content

Commit

Permalink
Disable ANSI colored debug output coloring when redirecting to a log …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
Galfurian committed Mar 5, 2024
1 parent 9c9b83e commit b459053
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ target_include_directories(libc PUBLIC inc)

# Remove the 'lib' prefix.
set_target_properties(libc PROPERTIES PREFIX "")

# If the emulator is set to output on a log file, tell that to the C code.
if(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_LOG)
target_compile_definitions(libc PUBLIC EMULATOR_OUTPUT_LOG)
endif()
2 changes: 2 additions & 0 deletions libc/src/io/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ static inline void __debug_print_header(const char *file, const char *fun, int l
log_level = 8;
}
// Set the color.
#ifndef EMULATOR_OUTPUT_LOG
dbg_puts(log_level_color[log_level]);
#endif
dbg_putchar('[');
// Set the label.
dbg_puts(log_level_label[log_level]);
Expand Down
5 changes: 5 additions & 0 deletions mentos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ target_compile_definitions(
${KERNEL_NAME} PUBLIC
__KERNEL__
)
# If the emulator is set to output on a log file, tell that to the C code.
if(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_LOG)
target_compile_definitions(${KERNEL_NAME} PUBLIC EMULATOR_OUTPUT_LOG)
endif()


# =============================================================================
# Enables cache tracing.
Expand Down
2 changes: 2 additions & 0 deletions mentos/src/io/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ static inline void __debug_print_header(const char *file, const char *fun, int l
log_level = 8;
}
// Set the color.
#ifndef EMULATOR_OUTPUT_LOG
dbg_puts(log_level_color[log_level]);
#endif
dbg_putchar('[');
// Set the label.
dbg_puts(log_level_label[log_level]);
Expand Down

0 comments on commit b459053

Please sign in to comment.